99 #if !defined (__TXLIB_H_INCLUDED) // <<<<<<<<< THE CODE IS HERE, UNFOLD IT <<<<<<<<<<<<<<<<<<<<<<<<<
100 #define __TXLIB_H_INCLUDED
131 #define _TX_VER _TX_v_FROM_CVS ($VersionInfo: , TXLib.h, 00173a, 166, 2020-05-15 02:04:56 +0400, "Ded (Ilya Dedinsky, http://txlib.ru) <mail@txlib.ru>", $)
132 #define _TX_VERSION _TX_V_FROM_CVS ($VersionInfo: , TXLib.h, 00173a, 166, 2020-05-15 02:04:56 +0400, "Ded (Ilya Dedinsky, http://txlib.ru) <mail@txlib.ru>", $)
133 #define _TX_AUTHOR _TX_A_FROM_CVS ($VersionInfo: , TXLib.h, 00173a, 166, 2020-05-15 02:04:56 +0400, "Ded (Ilya Dedinsky, http://txlib.ru) <mail@txlib.ru>", $)
136 #define _TX_v_FROM_CVS(_1,file,ver,rev,date,auth,_2) ((0x##ver##u << 16) | 0x##rev##u)
137 #define _TX_V_FROM_CVS(_1,file,ver,rev,date,auth,_2) "TXLib [Ver: " #ver ", Rev: " #rev ", Date: " #date "]"
138 #define _TX_A_FROM_CVS(_1,file,ver,rev,date,auth,_2) "Copyright (C) " auth
151 #if !defined (_TX_MODULE)
152 #define _TX_MODULE "TXLib"
161 #if defined (__GNUC__)
163 #define _GCC_VER ( __GNUC__*100 + __GNUC_MINOR__*10 + __GNUC_PATCHLEVEL__ )
165 #define __TX_COMPILER__ "GNU g++ " TX_QUOTE (__GNUC__) "." \
166 TX_QUOTE (__GNUC_MINOR__) "." \
167 TX_QUOTE (__GNUC_PATCHLEVEL__) \
168 ", std=" TX_QUOTE (__cplusplus)
170 #elif defined (__clang__) || defined (__clang_major__)
172 #define _CLANG_VER ( __clang_major__*100 + __clang_minor__*10 + __clang_patchlevel__ )
174 #define __TX_COMPILER__ "Clang " TX_QUOTE (__clang_major__) "." \
175 TX_QUOTE (__clang_minor__) "." \
176 TX_QUOTE (__clang_patchlevel__) \
177 ", std=" TX_QUOTE (__cplusplus)
178 #elif defined (_MSC_VER)
180 #define __TX_COMPILER__ "MSVS " TX_QUOTE (_MSC_VER) \
181 ", std=" TX_QUOTE (__cplusplus)
183 #elif defined (__INTEL_COMPILER)
185 #define __TX_COMPILER__ "Intel C++ " TX_QUOTE (__INTEL_COMPILER) \
186 ", std=" TX_QUOTE (__cplusplus)
189 #define __TX_COMPILER__ "Unknown C++, std=" TX_QUOTE (__cplusplus)
194 #define TX_QUOTE(sym) _TX_QUOTE (sym)
195 #define _TX_QUOTE(sym) #sym
197 #define TX_JOIN(sym1, sym2) _TX_JOIN (sym1, sym2)
198 #define _TX_JOIN(sym1, sym2) sym1 ## sym2
202 #if (__cplusplus >= 201103L) || defined (_MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013
207 #if (__cplusplus >= 201103L) || defined (_MSC_VER) && (_MSC_VER >= 1900) // MSVC 2015
209 #define _TX_CPP11_MSVC15 1
218 #if !defined (NDEBUG) && defined (_DEBUG)
219 #define _TX_BUILDMODE "DEBUG"
221 #elif !defined (NDEBUG) && !defined (_DEBUG)
222 #define _TX_BUILDMODE "Debug"
224 #elif defined (NDEBUG)
225 #define _TX_BUILDMODE "Release"
234 #define __TX_FILELINE__ __FILE__ " (" TX_QUOTE (__LINE__) ")"
246 #if defined (__GNUC__) || defined (__clang__) || defined (__clang_major__)
247 #define __TX_FUNCTION__ __PRETTY_FUNCTION__
249 #elif defined (__FUNCSIG__)
250 #define __TX_FUNCTION__ __FUNCSIG__
252 #elif defined (__FUNCTION__)
253 #define __TX_FUNCTION__ __FUNCTION__
255 #elif defined (__INTEL_COMPILER) && (__INTEL_COMPILER >= 600)
256 #define __TX_FUNCTION__ __FUNCTION__
258 #elif defined (__BORLANDC__) && (__BORLANDC__ >= 0x550)
259 #define __TX_FUNCTION__ __FUNC__
261 #elif defined (__cplusplus) && (__cplusplus >= 199711L)
262 #define __TX_FUNCTION__ __func__
264 #elif defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
265 #define __TX_FUNCTION__ __func__
267 #elif defined (__PYTHON__)
268 #error No Python. No. Using parseltongue languages can lead you to Slytherin.
271 #define __TX_FUNCTION__ "(" __TX_FILELINE__ ")"
275 #if !defined (__func__) && defined (__FUNCTION__)
276 #define __func__ __FUNCTION__
289 #if !defined (__cplusplus)
293 #error ---------------------------------------------------------------------------------------
295 #error TXLib.h: Must use C++ to compile TXLib.h. Now you are using C only.
297 #error CHECK source file EXTENSION. Maybe it is ".C". It must be ".CPP".
298 #error If your file is named, for example, "Untitled.C", go to menu [File],
299 #error then [Save As] and rename it to "Untitled.CPP". Please do NOT use spaces.
300 #error ---------------------------------------------------------------------------------------
307 #if !defined (WIN32) && !defined (__WIN32__) && !defined(_WIN32) && !defined(_WIN32_WINNT) && !defined (__CYGWIN__)
311 #error ---------------------------------------------------------------------------------------
313 #error TXLib.h: Windows (MSVC/Win32 or GCC/MinGW or Cygwin) is the only supported OS, sorry.
315 #error In Linux or MacOS, you should write your own TXLib and share it with your friends, or use wine.
316 #error ---------------------------------------------------------------------------------------
323 #if defined (UNICODE) || defined (_UNICODE)
326 #warning TXLib.h: Disabling the UNICODE
329 #undef UNICODE // Burn Unicode, burn
332 #if defined (_WINDOWS_H) || defined (_INC_WINDOWS) || defined (_WINDOWS_) || defined (__WINDOWS__)
336 #error ---------------------------------------------------------------------------------------
338 #error TXLib.h: Should include "TXLib.h" BEFORE or INSTEAD of <Windows.h> in UNICODE mode.
340 #error REARRANGE your #include directives, or DISABLE the UNICODE mode by #undef UNICODE/_UNICODE.
341 #error ---------------------------------------------------------------------------------------
350 #if defined (__STRICT_ANSI__) // Try to extend strict ANSI rules
352 #undef __STRICT_ANSI__
353 #define __STRICT_ANSI__UNDEFINED
355 #if defined (_STRING_H_) || defined (_INC_STRING) || defined (_STDIO_H_) || defined (_INC_STDIO)
359 #error ---------------------------------------------------------------------------------------
361 #error TXLib.h: Should include "TXLib.h" BEFORE <string.h> or <stdio.h> in Strict ANSI mode.
363 #error REARRANGE your #include directives, or DISABLE ANSI-compliancy by #undef __STRICT_ANSI__.
364 #error ---------------------------------------------------------------------------------------
373 #if defined (__GNUC__)
375 #pragma GCC diagnostic ignored "-Wpragmas"
377 #pragma GCC diagnostic warning "-Wall"
378 #pragma GCC diagnostic warning "-Weffc++"
379 #pragma GCC diagnostic warning "-Wextra"
381 #pragma GCC diagnostic warning "-Waggressive-loop-optimizations"
382 #pragma GCC diagnostic warning "-Walloc-zero"
383 #pragma GCC diagnostic warning "-Walloca"
384 #pragma GCC diagnostic warning "-Walloca-larger-than=8192"
385 #pragma GCC diagnostic warning "-Warray-bounds"
386 #pragma GCC diagnostic warning "-Wcast-align"
387 #pragma GCC diagnostic warning "-Wcast-qual"
388 #pragma GCC diagnostic warning "-Wchar-subscripts"
389 #pragma GCC diagnostic warning "-Wconditionally-supported"
390 #pragma GCC diagnostic warning "-Wconversion"
391 #pragma GCC diagnostic warning "-Wctor-dtor-privacy"
392 #pragma GCC diagnostic warning "-Wdangling-else"
393 #pragma GCC diagnostic warning "-Wduplicated-branches"
394 #pragma GCC diagnostic warning "-Wempty-body"
395 #pragma GCC diagnostic warning "-Wfloat-equal"
396 #pragma GCC diagnostic warning "-Wformat-nonliteral"
397 #pragma GCC diagnostic warning "-Wformat-overflow=2"
398 #pragma GCC diagnostic warning "-Wformat-security"
399 #pragma GCC diagnostic warning "-Wformat-signedness"
400 #pragma GCC diagnostic warning "-Wformat-truncation=2"
401 #pragma GCC diagnostic warning "-Wformat=2"
402 #pragma GCC diagnostic warning "-Wlarger-than=8192"
403 #pragma GCC diagnostic warning "-Wlogical-op"
404 #pragma GCC diagnostic warning "-Wmissing-declarations"
405 #pragma GCC diagnostic warning "-Wnarrowing"
406 #pragma GCC diagnostic warning "-Wnon-virtual-dtor"
407 #pragma GCC diagnostic warning "-Wnonnull"
408 #pragma GCC diagnostic warning "-Wopenmp-simd"
409 #pragma GCC diagnostic warning "-Woverloaded-virtual"
410 #pragma GCC diagnostic warning "-Wpacked"
411 #pragma GCC diagnostic warning "-Wpointer-arith"
412 #pragma GCC diagnostic warning "-Wredundant-decls"
413 #pragma GCC diagnostic warning "-Wrestrict"
414 #pragma GCC diagnostic warning "-Wshadow"
415 #pragma GCC diagnostic warning "-Wsign-promo"
416 #pragma GCC diagnostic warning "-Wstack-usage=8192"
417 #pragma GCC diagnostic warning "-Wstrict-aliasing"
418 #pragma GCC diagnostic warning "-Wstrict-null-sentinel"
419 #pragma GCC diagnostic warning "-Wstrict-overflow=2"
420 #pragma GCC diagnostic warning "-Wstringop-overflow=4"
421 #pragma GCC diagnostic warning "-Wsuggest-attribute=noreturn"
422 #pragma GCC diagnostic warning "-Wsuggest-final-methods"
423 #pragma GCC diagnostic warning "-Wsuggest-final-types"
424 #pragma GCC diagnostic warning "-Wsuggest-override"
425 #pragma GCC diagnostic warning "-Wswitch-default"
426 #pragma GCC diagnostic warning "-Wswitch-enum"
427 #pragma GCC diagnostic warning "-Wsync-nand"
428 #pragma GCC diagnostic warning "-Wundef"
429 #pragma GCC diagnostic warning "-Wunused"
430 #pragma GCC diagnostic warning "-Wvarargs"
431 #pragma GCC diagnostic warning "-Wvariadic-macros"
432 #pragma GCC diagnostic warning "-Wvla-larger-than=8192"
434 #pragma GCC diagnostic error "-Wsizeof-array-argument"
436 #pragma GCC diagnostic ignored "-Winline"
437 #pragma GCC diagnostic ignored "-Wliteral-suffix"
438 #pragma GCC diagnostic ignored "-Wmissing-field-initializers"
439 #pragma GCC diagnostic ignored "-Wnonnull-compare"
440 #pragma GCC diagnostic ignored "-Wold-style-cast"
441 #pragma GCC diagnostic ignored "-Wunreachable-code"
442 #pragma GCC diagnostic ignored "-Wunused-const-variable"
443 #pragma GCC diagnostic ignored "-Wunused-function"
445 #pragma GCC diagnostic warning "-Wpragmas"
449 #pragma GCC push_options
450 #pragma GCC diagnostic push
452 #pragma GCC diagnostic ignored "-Wpragmas"
454 #pragma GCC diagnostic ignored "-Waddress"
455 #pragma GCC diagnostic ignored "-Wclobbered"
456 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
457 #pragma GCC diagnostic ignored "-Wfloat-equal"
458 #pragma GCC diagnostic ignored "-Wformat-nonliteral"
459 #pragma GCC diagnostic ignored "-Wlarger-than="
460 #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
461 #pragma GCC diagnostic ignored "-Wredundant-decls"
462 #pragma GCC diagnostic ignored "-Wshadow"
463 #pragma GCC diagnostic ignored "-Wsign-conversion"
464 #pragma GCC diagnostic ignored "-Wstrict-aliasing"
465 #pragma GCC diagnostic ignored "-Wunused-label" // Just for fun in _txCanvas_OnCmdAbout()
466 #pragma GCC diagnostic ignored "-Wunused-value"
467 #pragma GCC diagnostic ignored "-Wformat-zero-length"
468 #pragma GCC diagnostic ignored "-Wpacked-not-aligned"
469 #pragma GCC optimize "no-strict-aliasing"
471 #if (__cplusplus < 201402L)
472 #pragma GCC diagnostic ignored "-Wsuggest-override"
475 #pragma GCC diagnostic warning "-Wpragmas"
477 #if defined (__CYGWIN__) && !defined (_TX_TESTING)
478 #pragma GCC system_header // This is not a fair play, but this is the only way to deal with Cygwin :(
483 #define _tx_thread __thread
484 #define _tx_decltype(value) __decltype (value)
486 #ifndef MINGW_HAS_SECURE_API
487 #define MINGW_HAS_SECURE_API 1
490 #if defined (TX_USE_SFML)
491 #define _GLIBCXX_NDEBUG
494 #ifndef _GLIBCXX_NDEBUG // TXLib enables _GLIBCXX_DEBUG by default. When using third-party libraries
495 #define _GLIBCXX_DEBUG // compiled without _GLIBCXX_DEBUG (SFML, for example), #define _GLIBCXX_NDEBUG
496 #define _GLIBCXX_DEBUG_PEDANTIC // *before* including TXLib.h.
499 #if defined (_WIN64) // removed in x86 because printf ("%lg", double) failure, this prints 0 always
500 #ifndef __USE_MINGW_ANSI_STDIO
501 #define __USE_MINGW_ANSI_STDIO 1
505 template <
typename T>
506 inline T _txNOP (T value) {
return value; }
509 extern "C" __declspec (dllimport)
unsigned __cdecl _controlfp (
unsigned control,
unsigned mask);
510 extern "C" void __cdecl _fpreset ();
514 #define __attribute__( attr )
515 #define _txNOP( value ) ( value )
521 #if defined (__clang__) || defined (__clang_major__)
523 #pragma clang diagnostic ignored "-Wunknown-pragmas"
525 #pragma clang diagnostic warning "-Wall"
526 #pragma clang diagnostic warning "-Weffc++"
527 #pragma clang diagnostic warning "-Wextra"
529 #pragma clang diagnostic warning "-Wcast-qual"
530 #pragma clang diagnostic warning "-Wchar-subscripts"
531 #pragma clang diagnostic warning "-Wconversion"
532 #pragma clang diagnostic warning "-Wctor-dtor-privacy"
533 #pragma clang diagnostic warning "-Wempty-body"
534 #pragma clang diagnostic warning "-Wfloat-equal"
535 #pragma clang diagnostic warning "-Wformat"
536 #pragma clang diagnostic warning "-Wformat-nonliteral"
537 #pragma clang diagnostic warning "-Wformat-security"
538 #pragma clang diagnostic warning "-Wmissing-declarations"
539 #pragma clang diagnostic warning "-Wnon-virtual-dtor"
540 #pragma clang diagnostic warning "-Woverloaded-virtual"
541 #pragma clang diagnostic warning "-Wpacked"
542 #pragma clang diagnostic warning "-Wpointer-arith"
543 #pragma clang diagnostic warning "-Wredundant-decls"
544 #pragma clang diagnostic warning "-Wshadow"
545 #pragma clang diagnostic warning "-Wsign-promo"
546 #pragma clang diagnostic warning "-Wstrict-aliasing"
547 #pragma clang diagnostic warning "-Wstrict-overflow"
548 #pragma clang diagnostic warning "-Wswitch-default"
549 #pragma clang diagnostic warning "-Wswitch-enum"
550 #pragma clang diagnostic warning "-Wunused"
551 #pragma clang diagnostic warning "-Wvariadic-macros"
553 #pragma clang diagnostic ignored "-Winvalid-source-encoding"
554 #pragma clang diagnostic ignored "-Wunused-const-variable"
555 #pragma clang diagnostic ignored "-Wunused-variable"
557 #pragma clang diagnostic warning "-Wunknown-pragmas"
561 #pragma clang diagnostic push
563 #pragma clang diagnostic ignored "-Wunknown-pragmas"
565 #pragma clang diagnostic ignored "-Wcast-align"
566 #pragma clang diagnostic ignored "-Wfloat-conversion"
567 #pragma clang diagnostic ignored "-Wmissing-braces"
568 #pragma clang diagnostic ignored "-Wmissing-field-initializers"
569 #pragma clang diagnostic ignored "-Wsign-compare"
570 #pragma clang diagnostic ignored "-Wsign-conversion"
571 #pragma clang diagnostic ignored "-Wstring-plus-int"
572 #pragma clang diagnostic ignored "-Wundef"
573 #pragma clang diagnostic ignored "-Wunused-function"
574 #pragma clang diagnostic ignored "-Wunused-value"
576 #pragma clang diagnostic warning "-Wunknown-pragmas"
604 #if defined (_MSC_VER)
606 #pragma warning (push, 4) // Set maximum warning level. This 'push' is to set the level only. It will NOT be popped.
608 #pragma warning (disable: 4616) // #pragma warning: warning number 'n' not a valid compiler warning
610 #pragma warning (disable: 4514) // Unreferenced inline function has been removed
611 #pragma warning (disable: 4710) // Function not inlined
612 #pragma warning (disable: 4786) // Identifier was truncated to '255' characters in the debug information
614 #pragma warning (error: 4715) // Not all control paths return a value
616 #pragma warning (default: 4616) // #pragma warning: warning number 'n' not a valid compiler warning
620 #pragma warning (push)
622 #pragma warning (disable: 4616) // #pragma warning: warning number 'n' not a valid compiler warning
624 #pragma warning (disable: 4091) // 'typedef': ignored on left of '...' when no variable is declared
625 #pragma warning (disable: 4124) // Using __fastcall with stack checking is ineffective
626 #pragma warning (disable: 4127) // Conditional expression is constant
627 #pragma warning (disable: 4200) // Nonstandard extension used: zero-sized array in struct/union
628 #pragma warning (disable: 4201) // Nonstandard extension used: nameless struct/union
629 #pragma warning (disable: 4351) // New behavior: elements of array will be default initialized
630 #pragma warning (disable: 4480) // Nonstandard extension used: specifying underlying type for enum 'type'
631 #pragma warning (disable: 4481) // Nonstandard extension used: override specifier 'override'
632 #pragma warning (disable: 4555) // Result of expression not used
633 #pragma warning (disable: 4611) // Interaction between '_setjmp' and C++ object destruction is non-portable
634 #pragma warning (disable: 5045) // Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified
635 #pragma warning (disable: 6269) // Possibly incorrect order of operations: dereference ignored
636 #pragma warning (disable: 6285) // (<non-zero constant>) || (<non-zero constant>) is always a non-zero constant. Did you intend to use bitwize-and operator?
637 #pragma warning (disable: 6319) // Use of the comma-operator in a tested expression causes the left argument to be ignored when it has no side-effects
638 #pragma warning (disable: 6326) // Potential comparison of a constant with another constant
639 #pragma warning (disable: 26135) // Missing locking annotation
640 #pragma warning (disable: 26400) // Do not assign the result of an allocation or a function call with an owner<T> return value to a raw pointer, use owner<T> instead (i.11).
641 #pragma warning (disable: 26401) // Do not delete a raw pointer that is not an owner<T> (i.11).
642 #pragma warning (disable: 26403) // Reset or explicitly delete an owner<T> pointer 'name' (r.3).
643 #pragma warning (disable: 26408) // Avoid malloc() and free(), prefer the nothrow version of new with delete (r.10).
644 #pragma warning (disable: 26409) // Avoid calling new and delete explicitly, use std::make_unique<T> instead (r.11).
645 #pragma warning (disable: 26426) // Global initializer calls a non-constexpr function 'name' (i.22).
646 #pragma warning (disable: 26429) // Symbol 'name' is never tested for nullness, it can be marked as not_null (f.23).
647 #pragma warning (disable: 26430) // Symbol 'name' is not tested for nullness on all paths (f.23).
648 #pragma warning (disable: 26432) // If you define or delete any default operation in the type 'struct 'name'', define or delete them all (c.21).
649 #pragma warning (disable: 26435) // Function 'name' should specify exactly one of 'virtual', 'override', or 'final' (c.128).
650 #pragma warning (disable: 26438) // Avoid 'goto' (es.76).
651 #pragma warning (disable: 26440) // Function 'name' can be declared 'noexcept' (f.6).
652 #pragma warning (disable: 26446) // Prefer to use gsl::at() instead of unchecked subscript operator (bounds.4).
653 #pragma warning (disable: 26447) // The function is declared 'noexcept' but calls function 'func' which may throw exceptions (f.6).
654 #pragma warning (disable: 26448) // Consider using gsl::finally if final action is intended (gsl.util).
655 #pragma warning (disable: 26451) // Arithmetic overflow: Using operator 'op' on a n-byte value and then casting the result to a m-byte value. Cast the value to the wider type before calling operator 'op' to avoid overflow (io.2).
656 #pragma warning (disable: 26455) // Default constructor may not throw. Declare it 'noexcept' (f.6).
657 #pragma warning (disable: 26460) // The reference argument 'stream' for function 'name' can be marked as const (con.3).
658 #pragma warning (disable: 26461) // The pointer argument 'name' for function 'name' can be marked as a pointer to const (con.3).
659 #pragma warning (disable: 26462) // The value pointed to by 'name' is assigned only once, mark it as a pointer to const (con.4).
660 #pragma warning (disable: 26475) // Do not use function style C-casts (es.49).
661 #pragma warning (disable: 26477) // Use 'nullptr' rather than 0 or NULL (es.47).
662 #pragma warning (disable: 26481) // Don't use pointer arithmetic. Use span instead (bounds.1).
663 #pragma warning (disable: 26482) // Only index into arrays using constant expressions (bounds.2).
664 #pragma warning (disable: 26483) // Value 'value' is outside the bounds (min, max) of variable 'name'. Only index into arrays using constant expressions that are within bounds of the array (bounds.2).
665 #pragma warning (disable: 26485) // Expression 'expr': No array to pointer decay (bounds.3).
666 #pragma warning (disable: 26486) // Don't pass a pointer that may be invalid to a function. Parameter 'n' 'name' in call to 'name' may be invalid (lifetime.3).
667 #pragma warning (disable: 26487) // Don't return a pointer 'name' that may be invalid (lifetime.4).
668 #pragma warning (disable: 26488) // Do not dereference a potentially null pointer: 'name'. 'name' was null at line 'n' (lifetime.1).
669 #pragma warning (disable: 26489) // Don't dereference a pointer that may be invalid: 'name'. 'name' may have been invalidated at line 'n' (lifetime.1).
670 #pragma warning (disable: 26490) // Don't use reinterpret_cast (type.1).
671 #pragma warning (disable: 26492) // Don't use const_cast to cast away const or volatile (type.3).
672 #pragma warning (disable: 26493) // Don't use C-style casts (type.4).
673 #pragma warning (disable: 26496) // The variable 'name' is assigned only once, mark it as const (con.4).
674 #pragma warning (disable: 26497) // The function 'name' could be marked constexpr if compile-time evaluation is desired (f.4).
675 #pragma warning (disable: 26812) // The enum type 'type' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
676 #pragma warning (disable: 26814) // The const variable 'name' can be computed at compile-time. Consider using constexpr (con.5).
677 #pragma warning (disable: 28125) // The function must be called from within a try/except block
678 #pragma warning (disable: 28159) // Consider using another function instead
680 #pragma warning (default: 4616) // #pragma warning: warning number 'n' not a valid compiler warning
682 #define _tx_thread __declspec (thread)
683 #define _tx_decltype(value) decltype (value)
685 #if !defined (_CLANG_VER)
687 #pragma setlocale ("russian") // Set source file encoding, see also _TX_CODEPAGE
689 #if !defined (NDEBUG)
690 #pragma check_stack ( on) // Turn on stack probes at runtime
691 #pragma strict_gs_check (push, on) // Detects stack buffer overruns
696 #define _CRT_SECURE_CPP_OVERLOAD_SECURE_NAMES 1
702 #if defined (__INTEL_COMPILER)
704 #pragma warning (disable: 174) // Remark: expression has no effect
705 #pragma warning (disable: 304) // Remark: access control not specified ("public" by default)
706 #pragma warning (disable: 444) // Remark: destructor for base class "..." is not virtual
707 #pragma warning (disable: 522) // Remark: function "..." redeclared "inline" after being called
708 #pragma warning (disable: 981) // Remark: operands are evaluated in unspecified order
709 #pragma warning (disable: 1684) // Conversion from pointer to same-sized integral type (potential portability problem)
715 #if (defined (_GCC_VER) && (_GCC_VER < 472) || \
716 defined (_MSC_VER) && (_MSC_VER < 1600)) // Minimum requirements are now GCC 4.7.2 or MSVC 10.0 (2010)
720 #error ---------------------------------------------------------------------------------------
722 #error TXLib.h: This version will NOT work with GCC < 4.7.2 or MS Visual Studio < 2010, sorry.
724 #error Please use TXLib.h previous stable version/revision OR upgrade your compiler.
725 #error ---------------------------------------------------------------------------------------
732 #if defined (_GCC_VER) && (_GCC_VER >= 492)
733 #if defined (TX_USE_SPEAK) && !__has_include (<SAPI.h>)
737 #error ---------------------------------------------------------------------------------------
739 #error You have defined TX_USE_SPEAK, but your compiler do NOT have the library <SAPI.h>.
741 #error Please use compiler library set with SAPI.h included. SAPI is Microsoft Speech API
742 #error nesessary for txSpeak() to work.
743 #error ---------------------------------------------------------------------------------------
751 #if !defined (WINVER)
752 #define WINVER 0x0500 // Defaults to Windows 2000
753 #define WINDOWS_ENABLE_CPLUSPLUS // Allow use of type-limit macros in <basetsd.h>,
754 #endif // they are allowed by default if WINVER >= 0x0600.
756 #if !defined (_WIN32_WINNT)
757 #define _WIN32_WINNT WINVER // Defaults to the same as WINVER
760 #if !defined (_WIN32_IE)
761 #define _WIN32_IE WINVER // Defaults to the same as WINVER
764 #define stristr( str1, str2 ) Win32::StrStrIA ((str1), (str2))
765 #define stristrw( str1, str2 ) Win32::StrStrIW ((str1), (str2))
769 #define _USE_MATH_DEFINES 1 // Math.h's M_PI etc.
770 #define __STDC_FORMAT_MACROS 1 // PRIu64 and other PR... macros
771 #define __STDC_WANT_LIB_EXT1__ 1 // String and output *_s functions
773 #define _LIBCPP_ENABLE_CXX17_REMOVED_UNEXPECTED_FUNCTIONS // Wow, how long. Kudos, Clang
775 #define _ALLOW_RTCc_IN_STL 1 // MSVC C2338: /RTCc rejects conformant code, so it isn't supported by libc.
777 #define NOMINMAX 1 // Preventing 'min' and 'max' defines in Windows.h
780 #define _SECURE_SCL 1 // Enable checked STL iterators to throw an exception on incorrect use
781 #define _HAS_ITERATOR_DEBUGGING 1
782 #define _LIBCPP_DEBUG 1
785 #if defined (_MSC_VER) && defined (_DEBUG)
787 #define _CRTDBG_MAP_ALLOC // Enable MSVCRT debug heap
788 #define _new_dbg new (_NORMAL_BLOCK, __FILE__, __LINE__)
789 #define NEW new (_NORMAL_BLOCK, __FILE__, __LINE__)
797 #if !( defined (_MSC_VER) && (_MSC_VER < 1900) ) // MSVC 2015
798 #define _SECURE_SCL_THROWS 1
801 #if defined (_TX_CPP11)
803 #define _tx_delete = delete
804 #define _tx_default = default
805 #define _tx_override override
806 #define _tx_final final
817 namespace std {
enum nomeow_t { nomeow }; }
829 #if defined (_MSC_VER)
830 #pragma warning (push, 3) // MSVC: At level /Wall, some std headers emit warnings... O_o
832 #pragma warning (disable: 4365) // 'argument': conversion from 'long' to 'unsigned int', signed/unsigned mismatch
833 #pragma warning (disable: 4005) // 'name': macro redefinition
867 #include <windowsx.h>
868 #include <tlhelp32.h>
869 #include <shellapi.h>
871 #if defined (_GCC_VER)
880 #if defined (__CYGWIN__)
893 #if defined (_MSC_VER)
898 #include <ntstatus.h>
905 #if defined (_GCC_VER) || defined (_MSC_VER) && (_MSC_VER >= 1800) // MSVC 2013
906 #include <inttypes.h>
911 #if defined (TX_USE_SPEAK) //--------------------------------------------------------------------------------------
913 #endif //--------------------------------------------------------------------------------------
920 #if defined (_MSC_VER)
921 #pragma warning (pop) // MSVC: Restore max level
924 #if defined (__STRICT_ANSI__UNDEFINED)
925 #define __STRICT_ANSI__ // Redefine back
928 #if !defined (_TRUNCATE) || defined (__CYGWIN__) || defined (_MEMORY_S_DEFINED)
930 #define strncpy_s( dest, sizeof_dest, src, count ) ( strncpy ((dest), (src), MIN ((count), (sizeof_dest))) )
931 #define wcsncpy_s( dest, sizeof_dest, src, count ) ( wcsncpy ((dest), (src), MIN ((count), (sizeof_dest))) )
932 #define strncat_s( dest, sizeof_dest, src, count ) ( strncat ((dest), (src), MIN ((count), (sizeof_dest))) )
933 #define strerror_s( buf, sizeof_buf, code ) ( strncpy ((buf), strerror ((int)(code)), (sizeof_buf)-1) )
934 #define strtok_s( buf, delim, ctx ) ( (void)(ctx), strtok ((buf), (delim)) )
935 #define fopen_s( file, name, mode ) ( *(file) = fopen ((name), (mode)) )
936 #define _strlwr_s( str, sizeof_str ) ( _strlwr (str) )
938 #define ctime_s( buf, sizeof_buf, time ) ( strncpy ((buf), ctime (time), (sizeof_buf)-1) )
939 #define _controlfp_s( oldCtl, newCtl, mask ) ( assert (oldCtl), *(oldCtl) = _controlfp (newCtl, mask), 0 )
941 #define _snprintf_s snprintf
942 #define _vsnprintf_s( str, sz, trunc, format, arg ) _vsnprintf (str, sz, format, arg)
944 #define _wsplitpath_s( path, drive, szDrive, \
945 dir, szDir, name, szName, \
946 ext, szExt ) _wsplitpath ( path, drive, dir, fname, ext )
949 #if !( defined (_MSC_VER) || defined (__STDC_LIB_EXT1__) )
951 #define getenv_s( sz, buf, sizeof_buf, name ) ( (void)(sz), strncpy ((buf), getenv (name), (sizeof_buf)-1) )
955 #if defined (__CYGWIN__)
957 #undef __STRICT_ANSI__
959 typedef void _exception;
961 #define _O_TEXT O_TEXT
962 #define _fdopen fdopen
963 #define _flushall() fflush (NULL)
964 #define _getcwd getcwd
965 #define _getpid getpid
966 #define _stricmp strcasecmp
967 #define _strlwr strlwr
968 #define _strnicmp strncasecmp
969 #define _unlink unlink
970 #define _vsnprintf vsnprintf
971 #define _access access
972 #define _strdup strdup
980 #if defined (IN) // IN and OUT are defined in WinDef.h to support Microsoft SAL.
981 #undef IN // Remove them because these names are often confused with the
982 #endif // user's code.
988 #define tx_nodiscard __attribute__ (( warn_unused_result ))
989 #define tx_deprecated __attribute__ (( deprecated ))
990 #define tx_printfy( formatArgNum ) __attribute__ (( format (printf, (formatArgNum), (formatArgNum)+1) ))
991 #define tx_scanfy( formatArgNum ) __attribute__ (( format (scanf, (formatArgNum), (formatArgNum)+1) ))
993 #if !defined (PRId64) || \
994 defined (_GCC_VER) && (_GCC_VER == 492) && !defined (_WIN64) // Dev-CPP 5.11: TDM-GCC 4.9.2 MinGW64 with -m32
1003 #define PRId64 "I64d"
1004 #define PRIi64 "I64i"
1005 #define PRIo64 "I64o"
1006 #define PRIu64 "I64u"
1007 #define PRIx64 "I64x"
1008 #define PRIX64 "I64X"
1027 #ifdef FOR_DOXYGEN_ONLY
1028 namespace {
namespace TX { }}
1036 namespace {
namespace TX {
1404 #ifdef FOR_DOXYGEN_ONLY
1436 #ifdef FOR_DOXYGEN_ONLY
1441 #define TX_GREY TX_GRAY
1442 #define TX_DARKGREY TX_DARKGRAY
1443 #define TX_LIGHTGREY TX_LIGHTGRAY
1473 #ifdef FOR_DOXYGEN_ONLY
1474 COLORREF RGB (
int red,
int green,
int blue);
1501 #define txSetColour txSetColor
1519 COLORREF txColor (
double red,
double green,
double blue);
1560 #define txSetFillColour txSetFillColor
1578 COLORREF txFillColor (
double red,
double green,
double blue);
1754 inline
bool txPixel (
double x,
double y,
double red,
double green,
double blue, HDC dc =
txDC());
1802 bool txLine (
double x0,
double y0,
double x1,
double y1, HDC dc =
txDC());
1925 bool txArc (
double x0,
double y0,
double x1,
double y1,
double startAngle,
double totalAngle, HDC dc =
txDC());
1952 bool txPie (
double x0,
double y0,
double x1,
double y1,
double startAngle,
double totalAngle, HDC dc =
txDC());
1979 bool txChord (
double x0,
double y0,
double x1,
double y1,
double startAngle,
double totalAngle, HDC dc =
txDC());
2037 bool txTriangle (
double x1,
double y1,
double x2,
double y2,
double x3,
double y3);
2038 bool txTriangle (
double x1,
double y1,
double x2,
double y2,
double x3,
double y3)
2040 (void)x1; (void)y1; (void)x2; (void)y2; (void)x3; (void)y3;
2043 "txTriangle (double x1, double y1, double x2, double y2, double x3, double y3)\n\n"
2045 " , txPolygon(). . \" ". "
" . :)",
"TXLib ", MB_ICONINFORMATION);
return false;
}
//{----------------------------------------------------------------------------------------------------------------
//! @cond INTERNAL
#define txRectandle Sleep (1000), txRectangle // Copy-protection for the function below
#define txCircle ;txCircle //
#define txSetColor ;txSetColor //
#define C0L0RREF COLORREF //
#define OxFFFFFF 0xFFFFFF //
#define lO 10 //
#define lOOO 1000 //
#define O //
bool txNotifyIcon (unsigned flags, const char title[], const char format[], ...) tx_printfy (3);
//! @endcond
//}
//{----------------------------------------------------------------------------------------------------------------
//! @ingroup Drawing
//! @brief .
//!
//! , .
//!
//! @param x X- .
//! @param y Y- .
//! @param sizeX .
//! @param sizeY ( ).
//! @param color .
//! @param handL ( ).
//! @param handR ( ).
//! @param twist @a ( ).
//! @param head @a ( ).
//! @param eyes ( ).
//! @param wink (0 -- , -1 -- , +1 -- ).
//! @param crazy ( ).
//! @param smile ( ).
//! @param hair ( ).
//! @param wind , ( ).
//!
//! @see txSetFillColor(), txColors, RGB(), txLine(), txCircle()
//!
//! @usage @code
//! txCreateWindow (800, 600);
//!
//! //-----------+---+----+-----+-----+----------+-----+-----+-----+----+----+----+-----+-----+----+-----
//! // | x | y |sizeX|sizeY| color |handL|handR|twist|head|eyes|wink|crazy|smile|hair|wind
//! //-----------+---+----+-----+-----+----------+-----+-----+-----+----+----+----+-----+-----+----+-----
//! // | | | | | | | | | | | | | | |
//! txDrawMan (125, 250, 200, 200, TX_WHITE, 0, 0, 0, 0, 0.8, 0, 0, 1.0, 0, 0);
//! txDrawMan (325, 250, 100, 200, TX_YELLOW, 0, 0, 0, 0, 0.8, 0, 0, -1.0, 2, 0);
//! txDrawMan (525, 250, 200, 100, TX_ORANGE, 0, 0, 0, 0, 1.0, 0, -1, 0.3, 1, 0);
//! txDrawMan (725, 250, 100, 100, TX_LIGHTRED, 0, 0, 0, 0, 1.0, 0, 1, -0.3, 3, 0);
//!
//! txDrawMan (125, 550, 200, 200, TX_WHITE, 0.3, 0.3, 0, 0, 0.8, -1, 1, 0.5, 2, -1);
//! txDrawMan (325, 550, 100, 200, TX_YELLOW, -0.5, -0.5, 0, 0.1, 0.8, 1, 0, -0.5, 3, 5);
//! txDrawMan (525, 550, 200, 100, TX_ORANGE, -0.5, 0.3, 0.2, 0, 0.8, -1, 1, 0.0, 10, -5);
//! txDrawMan (725, 550, 100, 100, TX_LIGHTRED, 0.3, -0.5, -0.4, 0, 0.8, 1, -1, 0.0, 1, 1);
//! @endcode
//}----------------------------------------------------------------------------------------------------------------//////
//
void txDrawMan (int x, int y, int sizeX, int sizeY, COLORREF color, double handL, double handR, double twist, //
double head, double eyes, double wink, double crazy, double smile, double hair, double wind) //
{ //
const char msg[] = "\0/ - !\0/ !\0/ !\0/"; //
// | | | | //
// ! _/ \_ ! :) _/ \_ _/ \_ ! :) _/ \_ ! //
// //
static int count = GetTickCount(), L = 0; //////////////////////////////////////////////////////////////////////////
C0L0RREF lineColor = txGetColor();
C0L0RREF fillColor = txGetFillColor();
txSetColor (color);
txSetFillColor (color);
txLine (x + twist * sizeX, y - O.35 * sizeY, x, y - O.7 * sizeY);
txLine (x, y - O.7 * sizeY, x - sizeX/2, y - (O.7 + handL) * sizeY);
txLine (x, y - O.7 * sizeY, x + sizeX/2, y - (O.7 + handR) * sizeY);
txLine (x + twist * sizeX, y - O.35 * sizeY, x - sizeX/2, y);
txLine (x + twist * sizeX, y - O.35 * sizeY, x + sizeX/2, y);
txCircle (x, y - (O.85 + head) * sizeY, O.15 * sizeY);
txLine (x, y - (1 + head) * sizeY, x + wind/lO * sizeX, y - (1 + head + hair/lO) * sizeY);
txLine (x, y - (1 + head) * sizeY, x + (wind/lO - O.1) * sizeX, y - (1 + head + hair/lO) * sizeY);
txLine (x, y - (1 + head) * sizeY, x + (wind/lO + O.1) * sizeX, y - (1 + head + hair/lO) * sizeY);
txSetColor (~color & OxFFFFFF); // Inverse the color
txSetFillColor (~color & OxFFFFFF);
txLine (x, y - (O.8 + head - O.05 * smile/2) * sizeY, x - O.05 * sizeY, y - (O.8 + head + O.05 * smile/2) * sizeY),
txLine (x, y - (O.8 + head - O.05 * smile/2) * sizeY, x + O.05 * sizeY, y - (O.8 + head + O.05 * smile/2) * sizeY),
txNotifyIcon (4, (const char*)!! (L+'L')[msg], "\n%s\n", msg + ((unsigned) (((count -=- 1) ^=! 1) ^=~ ((0)^(0)) +1) % 3)["\"<"]);
// See above: Mouth operator -=-, Cat operator ^=!, Mouse operator ^=~ and Owl constant ((0)^(0)). Use it freely, meow
txCircle (x - O.05 * sizeY, y - (O.9 + head - O.02 * crazy) * sizeY, eyes * (1 + O.5*wink) * O.02 * sizeY);
txCircle (x + O.05 * sizeY, y - (O.9 + head + O.02 * crazy) * sizeY, eyes * (1 - O.5*wink) * O.02 * sizeY),
Sleep (lOOO + count%2);
txSetColor (TX_DARKGRAY);
txSetFillColor (TX_TRANSPARENT);
txCircle (x, y, 4);
txRectandle (x - sizeX/2, y - sizeY, x + sizeX/2, y);
txSetColor (lineColor);
txSetFillColor (fillColor);
}
//! @}
//}
//=================================================================================================================
//=================================================================================================================
//{ Drawing text
//! @name
//=================================================================================================================
//! @{
//{----------------------------------------------------------------------------------------------------------------
//! @ingroup Drawing
//! @brief .
//!
//! @param x X- .
//! @param y Y- .
//! @param text .
//! @param dc <i> () . .</i>
//!
//! @return -- true, -- false.
//!
//! txSetColor(), (// ) -- txSetTextAlign().
//!
//! @see txSetColor(), txGetColor(), txSetFillColor(), txGetFillColor(), txColors, RGB(),
//! txSelectFont(), txSetTextAlign(), txGetTextExtent(), txGetTextExtentX(), txGetTextExtentY()
//!
//! @usage @code
//! txTextOut (100, 100, " .");
//! @endcode
//}----------------------------------------------------------------------------------------------------------------
bool txTextOut (double x, double y, const char text[], HDC dc = txDC());
//{----------------------------------------------------------------------------------------------------------------
//! @cond INTERNAL
#undef txRectandle
#undef txCircle
#undef txSetColor
#undef C0L0RREF
#undef OxFFFFFF
#undef lO
#undef lOOO
#undef O
//! @endcond
//}
//{----------------------------------------------------------------------------------------------------------------
//! @ingroup Drawing
//! @brief , .
//!
//! @param x0 X- .
//! @param y0 Y- .
//! @param x1 X- .
//! @param y1 Y- .
//! @param text .
//! @param format <i> . . , : ,
//! , .</i>
//! @param dc <i> () . .</i>
//!
//! @return -- true, -- false.
//!
//! txSetColor(), (// ) -- txSetTextAlign().
//!
//! @note , ( x0 > x1 y0 > y1).
//!
//! . MSDN (http://msdn.com), "DrawText Function (Windows)":
//! http://msdn.microsoft.com/en-us/library/dd162498%28VS.85%29.aspx.
//!
//! <b>
2047 "TXLib ", MB_ICONINFORMATION);
2055 #define txRectandle Sleep (1000), txRectangle // Copy-protection for the function below
2056 #define txCircle ;txCircle //
2057 #define txSetColor ;txSetColor //
2058 #define C0L0RREF COLORREF //
2059 #define OxFFFFFF 0xFFFFFF //
2061 #define lOOO 1000 //
2064 bool txNotifyIcon (
unsigned flags,
const char title[],
const char format[], ...)
tx_printfy (3);
2112 void txDrawMan (
int x,
int y,
int sizeX,
int sizeY, COLORREF color,
double handL,
double handR,
double twist,
2113 double head,
double eyes,
double wink,
double crazy,
double smile,
double hair,
double wind)
2115 const char msg[] =
"\0/ - !\0/ !\0/ !\0/";
2119 static int count = GetTickCount(), L = 0;
2127 txLine (x + twist * sizeX, y - O.35 * sizeY, x, y - O.7 * sizeY);
2129 txLine (x, y - O.7 * sizeY, x - sizeX/2, y - (O.7 + handL) * sizeY);
2130 txLine (x, y - O.7 * sizeY, x + sizeX/2, y - (O.7 + handR) * sizeY);
2132 txLine (x + twist * sizeX, y - O.35 * sizeY, x - sizeX/2, y);
2133 txLine (x + twist * sizeX, y - O.35 * sizeY, x + sizeX/2, y);
2135 txCircle (x, y - (O.85 + head) * sizeY, O.15 * sizeY);
2137 txLine (x, y - (1 + head) * sizeY, x + wind/lO * sizeX, y - (1 + head + hair/lO) * sizeY);
2138 txLine (x, y - (1 + head) * sizeY, x + (wind/lO - O.1) * sizeX, y - (1 + head + hair/lO) * sizeY);
2139 txLine (x, y - (1 + head) * sizeY, x + (wind/lO + O.1) * sizeX, y - (1 + head + hair/lO) * sizeY);
2144 txLine (x, y - (O.8 + head - O.05 * smile/2) * sizeY, x - O.05 * sizeY, y - (O.8 + head + O.05 * smile/2) * sizeY),
2145 txLine (x, y - (O.8 + head - O.05 * smile/2) * sizeY, x + O.05 * sizeY, y - (O.8 + head + O.05 * smile/2) * sizeY),
2146 txNotifyIcon (4, (
const char*)!! (L+
'L')[msg],
"\n%s\n", msg + ((
unsigned) (((count -=- 1) ^=! 1) ^=~ ((0)^(0)) +1) % 3)[
"\"<"]);
2150 txCircle (x - O.05 * sizeY, y - (O.9 + head - O.02 * crazy) * sizeY, eyes * (1 + O.5*wink) * O.02 * sizeY);
2151 txCircle (x + O.05 * sizeY, y - (O.9 + head + O.02 * crazy) * sizeY, eyes * (1 - O.5*wink) * O.02 * sizeY),
2152 Sleep (lOOO + count%2);
2158 txRectandle (x - sizeX/2, y - sizeY, x + sizeX/2, y);
2257 bool txDrawText (
double x0,
double y0,
double x1,
double y1,
const char text[],
2258 unsigned format = DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_WORD_ELLIPSIS, HDC dc =
txDC());
2288 int bold = FW_DONTCARE,
bool italic =
false,
bool underline =
false,
2289 bool strikeout =
false,
double angle = 0,
2710 bool txBitBlt (HDC destImage,
double xDest,
double yDest,
double width,
double height,
2711 HDC sourceImage,
double xSource = 0,
double ySource = 0,
unsigned operation = SRCCOPY);
2730 inline
bool txBitBlt (
double xDest,
double yDest, HDC sourceImage,
double xSource = 0,
double ySource = 0);
2790 HDC sourceImage,
double xSource = 0,
double ySource = 0, COLORREF transColor =
TX_BLACK);
2811 COLORREF transColor =
TX_BLACK,
double xSource = 0,
double ySource = 0);
2925 bool txAlphaBlend (HDC destImage,
double xDest,
double yDest,
double width,
double height,
2926 HDC sourceImage,
double xSource = 0,
double ySource = 0,
double alpha = 1.0);
2948 double xSource = 0,
double ySource = 0,
double alpha = 1.0);
3326 #if defined (_TX_CPP11)
3327 template <
int txFramesToAverage = 5>
3329 const int txFramesToAverage = 5;
3470 #ifdef FOR_DOXYGEN_ONLY
3471 inline Mouse& txCatchMouse (
bool shouldEat =
true);
3698 bool txPlaySound (const
char filename[] = NULL, DWORD mode = SND_ASYNC);
3820 intptr_t
txPlayVideo (
int x,
int y,
int width,
int height, const
char fileName[],
3821 double zoom = 0,
double gain = 1, HWND wnd =
txWindow());
3918 int txMessageBox (const
char text[] = "! :)", const
char header[] = "TXLib ",
3919 unsigned flags = MB_ICONINFORMATION | MB_OKCANCEL);
4020 #ifdef FOR_DOXYGEN_ONLY
4021 bool txNotifyIcon (
unsigned flags,
const char title[],
const char format[], ...)
tx_printfy (3);
4131 #if defined (_TX_CPP11) || defined (FOR_DOXYGEN_ONLY)
4133 template <
typename T,
typename... ArgsT>
4134 int txPrintf (
const char* format, ArgsT... args);
4136 #define TX_PRINTF(...) ( _txPrintfCheck (__VA_ARGS__), txPrintf (__VA_ARGS__) )
4142 #if defined (_TX_CPP11) && !defined (FOR_DOXYGEN_ONLY)
4144 enum width_t :
int {};
4145 enum precision_t :
int {};
4147 inline width_t width (
int width) {
return (width_t) width; }
4148 inline precision_t precision (
int prec) {
return (precision_t) prec; }
4172 #if defined (_TX_CPP11) || defined (FOR_DOXYGEN_ONLY)
4174 template <
typename T,
typename... ArgsT>
4175 int txPrintf (std::ostringstream& stream,
const char* format, ArgsT... args);
4200 #if defined (_TX_CPP11) || defined (FOR_DOXYGEN_ONLY)
4202 template <
typename T,
typename... ArgsT>
4203 int txPrintf (
char buffer[],
size_t size,
const char* format, ArgsT... args);
4226 #if defined (_TX_CPP11) || defined (FOR_DOXYGEN_ONLY)
4228 template <
typename... ArgsT>
4229 std::string txFormat (
const char* format, ArgsT... args);
4308 #define sizearr( arr ) ( sizeof (get_size_of_an_array_with_unknown_or_nonconst_size_ (arr)) )
4313 template <
typename T,
size_t N> char (&get_size_of_an_array_with_unknown_or_nonconst_size_ (T (&) [N])) [N];
4317 #if defined (_TX_CPP11_MSVC15)
4318 template <
typename T,
size_t N> constexpr
size_t countof (
const T (&) [N] ) {
return N; }
4323 #define SIZEARR( arr ) ( sizeof (arr) / sizeof ((arr)[0]) )
4403 template <
typename Tx,
typename Ta,
typename Tb>
4406 template <
typename Tx,
typename Ta,
typename Tb>
4484 #define MAX( a, b ) ( ((a) > (b))? (a) : (b) )
4507 #define MIN( a, b ) ( ((a) < (b))? (a) : (b) )
4525 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L // MSVC: C99 case
4527 #define ROUND( x ) ( (long) round (x) )
4531 #define ROUND( x ) ( (long) floor ((x) + 0.5) )
4569 const double txPI = asin (1.0) * 2;
4602 double sqr = pow (sqrt (x) * sqrt (x), sqrt (4.0));
4604 char str[1024] =
"";
4605 _snprintf_s (str,
sizeof (str),
" %g!" "!!" "!!" " ????", sqr);
4606 txMessageBox (str,
" !" "!!", MB_ICONEXCLAMATION | MB_YESNO) != IDNO ||
4608 txMessageBox (
"...",
" , MB_ICONINFORMATION),
txMessageBox (" ", " ...", MB_ICONSTOP),
exit (EXIT_FAILURE), 0
);
txNotifyIcon (1, NULL, "\n%s\n", " ! \0" // , ?
" ... \0" //
" \0" //
" - \0" // ?..
", \0"
" ?\0" + GetTickCount() % 6 * 21);
return sqr; // .
}
//{----------------------------------------------------------------------------------------------------------------
//! @ingroup Misc
//! @brief <i> <b>, MB_ICONINFORMATION),
4609 txMessageBox (
" , " ...", MB_ICONSTOP),
exit (EXIT_FAILURE), 0
);
txNotifyIcon (1, NULL, "\n%s\n", " ! \0" // , ?
" ... \0" //
" \0" //
" - \0" // ?..
", \0"
" ?\0" + GetTickCount() % 6 * 21);
return sqr; // .
}
//{----------------------------------------------------------------------------------------------------------------
//! @ingroup Misc
//! @brief <i> <b>, " ...", MB_ICONSTOP),
4610 exit (EXIT_FAILURE), 0
4613 txNotifyIcon (1, NULL,
"\n%s\n",
" ! \0"
4618 " ?\0" + GetTickCount() % 6 * 21);
4647 #ifdef FOR_DOXYGEN_ONLY
4648 #define _TX_DESTROY_3D
4651 #if defined (_TX_DESTROY_3D)
4681 #if defined (_MSC_VER) && !defined (_CLANG_VER)
4707 #define ZERO( type ) zero <type> ()
4743 #define tx_auto_func( func ) _tx_auto_fun1 ( __LINE__, func )
4744 #define _tx_auto_fun1( n, func ) _tx_auto_fun2 ( n, func )
4745 #define _tx_auto_fun2( n, func ) auto _tx_auto_func_##n = _tx_auto_func ([&]() { func; })
4747 #define tx_finally(...) tx_auto_func (__VA_ARGS__)
4749 template <
typename T>
4760 this_t& operator = (const this_t&) _tx_delete;
4763 template <typename T>
4816 #if !defined (NDEBUG)
4818 #define TX_ASSERT( cond ) _txNOP ( !(cond)? (TX_ERROR ("\a" ": : " \
4819 ", \"%s\"." TX_COMMA #cond), 1/(int)!!(cond)) : 1 )
4822 #define TX_ASSERT( cond ) ((void) 1)
4830 #define assert( cond ) TX_ASSERT (cond)
4861 #if !defined (NDEBUG)
4862 #define asserted || TX_ERROR ("\a" " .")
4865 #define asserted || _txNOP (0)
4869 #define verified asserted
4871 #define TX_NEEDED asserted
4905 #if !defined (NDEBUG)
4907 #define verify assert
4911 #define verify( expr ) ( expr )
4936 #if !defined (FOR_DOXYGEN_ONLY)
4937 #define TX_ERROR( ... ) _txError (__FILE__, __LINE__, __TX_FUNCTION__, 0, ##__VA_ARGS__)
4939 #define TX_ERROR( msg ) _txError (__FILE__, __LINE__, __TX_FUNCTION__, 0, msg)
4943 #define TX_THROW TX_ERROR
4964 #if !defined (NDEBUG)
4965 #define TX_DEBUG_ERROR(...) TX_ERROR (__VA_ARGS__)
4968 #define TX_DEBUG_ERROR(...) ((void) 0)
4994 #ifdef FOR_DOXYGEN_ONLY
4995 void txDump (
const void* address,
const char name[] =
"_txDump()",
bool pause =
true);
5001 #define txDump( ... ) _txDump ((const void*)(uintptr_t) __VA_ARGS__)
5003 #define txDump( address, ... ) _txDump ((const void*)(uintptr_t) (address), #address, ##__VA_ARGS__)
5006 void _txDump (
const void* address,
const char name[] =
"_txDump()",
bool pause =
true);
5038 #define txStackBackTrace() _txStackBackTrace (__FILE__, __LINE__, __TX_FUNCTION__, true);
5068 #define txTypename(value) txDemangle (typeid (value) .name()) .c_str()
5100 int txRegQuery (
const char* keyName,
const char* valueName,
void* value,
size_t szValue);
5261 template <
typename T>
inline T
txUnlock (T value);
5291 #define txGDI( command, dc ) ( ((dc) == txDC())? txUnlock ( (txLock(), (command)) ) : (command) )
5318 #ifndef FOR_DOXYGEN_ONLY
5391 #if defined (_TX_NOINIT)
5394 #define _TX_NOINIT 1
5398 #define _TX_NOINIT 0
5474 #ifdef FOR_DOXYGEN_ONLY
5483 #if !defined (TX_TRACE)
5491 #if defined (_TX_USE_DEVPARTNER)
5540 HDC src,
int xSrc,
int ySrc,
int wSrc,
int hSrc, DWORD rOp) = NULL;
5558 #if !defined (_TX_EXCEPTIONS_LIMIT)
5559 #define _TX_EXCEPTIONS_LIMIT 16
5562 #if !defined (_TX_FATAL_EXCEPTIONS_LIMIT)
5563 #define _TX_FATAL_EXCEPTIONS_LIMIT 16
5571 #ifdef FOR_DOXYGEN_ONLY
5572 #define _TX_FULL_STACKTRACE
5592 #if !defined (_TX_WAITABLE_PARENTS)
5593 #define _TX_WAITABLE_PARENTS "Winpty-agent.exe:Clion.exe, " \
5594 "Winpty-agent.exe:Clion64.exe, " \
5595 "starter.exe:eclipse.exe, " \
5596 "starter.exe:javaw.exe, " \
5597 "cmd.exe:devenv.exe, " \
5598 "VSDebugConsole.exe:devenv.exe, " \
5599 "consolepauser.exe:devcpp.exe, " \
5600 "cb_console_runner.exe:codeblocks.exe"
5624 #if !defined (_TX_ALLOW_KILL_PARENT) // DISCLAIMER: .
5625 #define _TX_ALLOW_KILL_PARENT true // .
5693 #ifdef FOR_DOXYGEN_ONLY
5694 #define _TX_ALLOW_TRACE
5729 #ifdef FOR_DOXYGEN_ONLY
5733 #if !defined (TX_TRACE)
5734 #define TX_TRACE { if (_txLoc::Cur.trace) _txTrace (__FILE__, __LINE__, __TX_FUNCTION__); }
5738 void _txTrace (
const char file[],
int line,
const char func[],
const char msg[] = NULL, ...);
5744 #ifndef FOR_DOXYGEN_ONLY
5757 static _txLoc _tx_thread Cur;
5762 typedef _txFuncEntry this_t;
5766 _txFuncEntry() : loc (_txLoc::Cur) { _txLoc::Cur.inTX++; _txLoc::Cur.prev = &loc; }
5767 void restore() { _txLoc::Cur = loc; }
5768 ~_txFuncEntry() { restore(); }
5771 _txFuncEntry (
const this_t&) _tx_delete;
5772 this_t& operator = (
const this_t&) _tx_delete;
5775 #if defined (_GCC_VER)
5777 inline void __txLocCurSet (
const char* _file,
int _line,
const char* _func)
5778 { _txLoc::Cur.file = _file; _txLoc::Cur.line = _line; _txLoc::Cur.func = _func; }
5782 #define __txLocCurSet( _file, _line, _func ) \
5783 ( _txLoc::Cur.file = (_file), _txLoc::Cur.line = (_line), _txLoc::Cur.func = (_func) )
5787 #define _txLocCurSet() __txLocCurSet (__FILE__, __LINE__, __TX_FUNCTION__)
5789 #define _txLocLvlSet(lvl) { _txLoc::Cur.trace = (lvl); }
5844 #if defined (_TX_ALLOW_TRACE)
5846 #define _txEntry(lvl) _txFuncEntry __txFuncEntry; { if (lvl) _txLocLvlSet (lvl); $; }
5848 #define $ { _txLocCurSet(); if (_txLoc::Cur.trace <= _TX_ALLOW_TRACE+0) { TX_TRACE; } }
5850 #define $$ { __txFuncEntry.restore(); }
5852 #elif defined (_DEBUG)
5854 #define _txEntry(lvl) _txFuncEntry __txFuncEntry; { $; }
5856 #define $ { _txLocCurSet(); }
5858 #define $$ { __txFuncEntry.restore(); }
5862 #define _txEntry(lvl) ;
5870 #define $0 _txEntry (0) // (Log level unchanged)
5871 #define $1 _txEntry (1) // Regular functions
5872 #define $2 _txEntry (2) // Resvd
5873 #define $3 _txEntry (3) // Init/Cleanup
5874 #define $4 _txEntry (4) // Init/Cleanup, misc functions
5875 #define $5 _txEntry (5) // Error handling, entry points
5876 #define $6 _txEntry (6) // Error handling, main part
5877 #define $7 _txEntry (7) // Error handling, misc functions
5878 #define $8 _txEntry (8) // Canvas worker thread
5879 #define $9 _txEntry (9) // Resvd
5884 #endif // FOR_DOXYGEN_ONLY
5916 extern CRITICAL_SECTION _txCanvas_LockBackBuf;
5950 explicit txAutoLock (CRITICAL_SECTION* cs,
bool mandatory =
true) :
5953 $1
if (!cs_)
return;
5955 if (mandatory) {$ EnterCriticalSection (cs_); }
5956 else {$ TryEnterCriticalSection (cs_)? 0 : (cs_ = NULL); }
5977 $1
new (
this)
txAutoLock (&_txCanvas_LockBackBuf, mandatory);
5986 $1
if (!cs_)
return;
5987 $ LeaveCriticalSection (cs_); cs_ = NULL;
5995 operator bool ()
const
5997 $1
return (cs_ != NULL);
6073 DIALOG = (int) 0x00000000,
6074 BUTTON = (
int) 0xFFFF0080,
6075 EDIT = (int) 0xFFFF0081,
6076 STATIC = (
int) 0xFFFF0082,
6077 LISTBOX = (int) 0xFFFF0083,
6078 SCROLLBAR = (
int) 0xFFFF0084,
6079 COMBOBOX = (int) 0xFFFF0085,
6080 END = (
int) 0x00000000
6187 virtual int dialogProc (HWND _wnd, UINT _msg, WPARAM _wParam, LPARAM _lParam);
6239 static intptr_t CALLBACK
DialogProc_ (HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam);
6281 #define TX_BEGIN_MESSAGE_MAP() \
6282 virtual int dialogProc (HWND _wnd, UINT _msg, WPARAM _wParam, LPARAM _lParam) _tx_override \
6284 int _result = txDialog::dialogProc (_wnd, _msg, _wParam, _lParam); (void) _result; \
6311 #define TX_HANDLE( id ) \
6337 #define TX_COMMAND_MAP \
6341 if (_msg == WM_COMMAND) switch (LOWORD (_wParam)) \
6366 #define TX_END_MESSAGE_MAP \
6404 const char*
txInputBox (
const char* text = NULL,
const char* caption = NULL,
const char* input = NULL)
tx_nodiscard;
6406 const char*
txInputBox (
const char* text,
const char* caption,
const char* input)
6413 if (!text) text =
" :";
6415 if (!input) input =
"";
6425 #define ID_TEXT_ 101
6426 #define ID_INPUT_ 102
6446 {
txDialog::BUTTON,
"&OK", IDOK, 180, 10, 50, 15, BS_DEFPUSHBUTTON | WS_TABSTOP },
6447 {
txDialog::BUTTON,
"&Cancel", IDCANCEL, 180, 30, 50, 15, BS_PUSHBUTTON | WS_TABSTOP },
6503 static inputDlg dlg;
6509 dlg.dialogBox (layout);
6546 #ifndef AC_SRC_ALPHA
6547 #define AC_SRC_ALPHA 0x01
6550 #ifndef SMTO_ERRORONEXIT
6551 #define SMTO_ERRORONEXIT 0x0020
6554 #ifndef NT_CONSOLE_PROPS_SIG
6555 #define NT_CONSOLE_PROPS_SIG 0xA0000002
6559 #define NIIF_INFO 0x00000001
6560 #define NIIF_WARNING 0x00000002
6561 #define NIIF_ERROR 0x00000003
6565 #define NIF_STATE 0x00000008
6566 #define NIF_INFO 0x00000010
6569 #ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
6570 #define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 0x00000004
6573 #ifndef SYMOPT_CASE_INSENSITIVE
6574 #define SYMOPT_CASE_INSENSITIVE 0x00000001
6575 #define SYMOPT_UNDNAME 0x00000002
6576 #define SYMOPT_DEFERRED_LOADS 0x00000004
6577 #define SYMOPT_NO_CPP 0x00000008
6578 #define SYMOPT_LOAD_LINES 0x00000010
6579 #define SYMOPT_OMAP_FIND_NEAREST 0x00000020
6580 #define SYMOPT_LOAD_ANYTHING 0x00000040
6581 #define SYMOPT_IGNORE_CVREC 0x00000080
6582 #define SYMOPT_NO_UNQUALIFIED_LOADS 0x00000100
6583 #define SYMOPT_FAIL_CRITICAL_ERRORS 0x00000200
6584 #define SYMOPT_EXACT_SYMBOLS 0x00000400
6585 #define SYMOPT_ALLOW_ABSOLUTE_SYMBOLS 0x00000800
6586 #define SYMOPT_IGNORE_NT_SYMPATH 0x00001000
6587 #define SYMOPT_INCLUDE_32BIT_MODULES 0x00002000
6588 #define SYMOPT_PUBLICS_ONLY 0x00004000
6589 #define SYMOPT_NO_PUBLICS 0x00008000
6590 #define SYMOPT_AUTO_PUBLICS 0x00010000
6591 #define SYMOPT_NO_IMAGE_SEARCH 0x00020000
6592 #define SYMOPT_SECURE 0x00040000
6593 #define SYMOPT_NO_PROMPTS 0x00080000
6594 #define SYMOPT_ALLOW_ZERO_ADDRESS 0x01000000
6595 #define SYMOPT_DISABLE_SYMSRV_AUTODETECT 0x02000000
6596 #define SYMOPT_FAVOR_COMPRESSED 0x00800000
6597 #define SYMOPT_FLAT_DIRECTORY 0x00400000
6598 #define SYMOPT_IGNORE_IMAGEDIR 0x00200000
6599 #define SYMOPT_OVERWRITE 0x00100000
6600 #define SYMOPT_DEBUG 0x80000000
6605 #ifndef STATUS_POSSIBLE_DEADLOCK
6606 #define STATUS_POSSIBLE_DEADLOCK 0xC0000194
6609 #ifndef STATUS_FLOAT_MULTIPLE_FAULTS
6610 #define STATUS_FLOAT_MULTIPLE_FAULTS 0xC00002B4
6613 #ifndef STATUS_STACK_BUFFER_OVERRUN
6614 #define STATUS_STACK_BUFFER_OVERRUN 0xC0000409
6617 #ifndef STATUS_ASSERTION_FAILURE
6618 #define STATUS_ASSERTION_FAILURE 0xC0000420
6621 #ifndef STATUS_WX86_BREAKPOINT
6622 #define STATUS_WX86_BREAKPOINT 0x4000001F
6625 #ifndef DBG_PRINTEXCEPTION_C
6626 #define DBG_PRINTEXCEPTION_C 0x40010006 // OutputDebugStringA() call
6629 #ifndef DBG_PRINTEXCEPTION_WIDE_C
6630 #define DBG_PRINTEXCEPTION_WIDE_C 0x4001000A // OutputDebugStringW() call
6633 #ifndef DBG_THREAD_NAME
6634 #define DBG_THREAD_NAME 0x406D1388
6637 #define EXCEPTION_CPP_MSC 0xE06D7363 // '?msc'
6638 #define EXCEPTION_CPP_MSC_EH_MAGIC_NUMBER1 0x19930520 // '?msc' version magic, see ehdata.h
6639 #define EXCEPTION_CPP_MSC_EH_MAGIC_NUMBER2 0x19930521 // '?msc' version magic
6640 #define EXCEPTION_CPP_MSC_EH_MAGIC_NUMBER3 0x19930522 // '?msc' version magic
6641 #define EXCEPTION_CPP_MSC_EH_PURE_MAGIC_NUMBER1 0x01994000 // '?msc' version magic
6643 #define EXCEPTION_CPP_GCC 0x20474343 // ' GCC'
6644 #define EXCEPTION_CPP_GCC_UNWIND 0x21474343 // '!GCC'
6645 #define EXCEPTION_CPP_GCC_FORCED 0x22474343 // '"GCC'
6647 #define EXCEPTION_CLR_FAILURE 0xE0434f4D // 'COM'
6649 #define EXCEPTION_CPP_BORLAND_BUILDER 0x0EEDFAE6 // Should never occur here
6650 #define EXCEPTION_CPP_BORLAND_DELPHI 0x0EEDFADE // Should never occur here
6652 #pragma pack (push, 1)
6654 struct CONSOLE_CURSOR_INFO
6660 struct CONSOLE_FONT_INFO
6666 struct CONSOLE_FONT_INFOEX
6673 WCHAR FaceName[LF_FACESIZE];
6676 struct DATABLOCK_HEADER
6682 struct NT_CONSOLE_PROPS
6684 DATABLOCK_HEADER dbh;
6686 WORD wFillAttribute;
6687 WORD wPopupFillAttribute;
6688 COORD dwScreenBufferSize;
6690 COORD dwWindowOrigin;
6692 DWORD nInputBufferSize;
6696 WCHAR FaceName[LF_FACESIZE];
6702 UINT uHistoryBufferSize;
6703 UINT uNumberOfHistoryBuffers;
6706 COLORREF ColorTable[16];
6712 #define INTERFACE IShellLinkDataList
6714 DECLARE_INTERFACE_ (IShellLinkDataList, IUnknown)
6717 STDMETHOD (QueryInterface) (THIS_ REFIID iid,
void** value) _tx_override PURE;
6718 STDMETHOD_(ULONG, AddRef) (THIS) _tx_override PURE;
6719 STDMETHOD_(ULONG, Release) (THIS) _tx_override PURE;
6722 STDMETHOD (AddDataBlock) (THIS_
void* dataBlock) PURE;
6723 STDMETHOD (CopyDataBlock) (THIS_ DWORD sig,
void** dataBlock) PURE;
6724 STDMETHOD (RemoveDataBlock) (THIS_ DWORD sig) PURE;
6725 STDMETHOD (GetFlags) (THIS_ DWORD* flags) PURE;
6726 STDMETHOD (SetFlags) (THIS_ DWORD flags) PURE;
6729 virtual ~IShellLinkDataList();
6732 const GUID IID_IShellLink = {0x000214ee, 0x0000, 0x0000, {0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
6733 const GUID IID_IShellLinkDataList = {0x45e2b4ae, 0xb1c3, 0x11d0, {0xb9,0x2f,0x00,0xa0,0xc9,0x03,0x12,0xe1}};
6734 const GUID IID_IPersistFile = {0x0000010b, 0x0000, 0x0000, {0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
6736 const GUID CLSID_SpVoice = {0x96749377, 0x3391, 0x11d2, {0x9e,0xe3,0x00,0xc0,0x4f,0x79,0x73,0x96}};
6737 const GUID IID_ISpVoice = {0x6c44df74, 0x72b9, 0x4992, {0xa1,0xec,0xef,0x99,0x6e,0x04,0x22,0xd4}};
6741 typedef DWORD NTSTATUS;
6742 typedef ULONG_PTR KAFFINITY;
6743 typedef LONG KPRIORITY;
6745 struct UNICODE_STRING
6748 USHORT MaximumLength;
6752 struct RTL_USER_PROCESS_PARAMETERS
6755 void* Reserved2[10];
6756 UNICODE_STRING ImagePathName;
6757 UNICODE_STRING CommandLine;
6767 RTL_USER_PROCESS_PARAMETERS* ProcessParameters;
6769 void* AtlThunkSListPtr;
6774 ULONG AtlThunkSListPtr32;
6775 void* Reserved9[45];
6776 BYTE Reserved10[96];
6777 void* PostProcessInitRoutine;
6778 BYTE Reserved11[128];
6779 void* Reserved12[1];
6783 struct PROCESS_BASIC_INFORMATION
6785 NTSTATUS ExitStatus;
6786 PEB* PebBaseAddress;
6787 KAFFINITY AffinityMask;
6788 KPRIORITY BasePriority;
6789 ULONG_PTR UniqueProcessId;
6790 ULONG_PTR InheritedFromUniqueProcessId;
6811 DWORD ThCallbackStack;
6812 DWORD ThCallbackBStore;
6815 DWORD64 KiCallUserMode;
6816 DWORD64 KeUserCallbackDispatcher;
6817 DWORD64 SystemRangeStart;
6818 DWORD64 KiUserExceptionDispatcher;
6821 DWORD64 Reserved[5];
6827 ADDRESS64 AddrReturn;
6828 ADDRESS64 AddrFrame;
6829 ADDRESS64 AddrStack;
6830 ADDRESS64 AddrBStore;
6831 PVOID FuncTableEntry;
6835 DWORD64 Reserved[3];
6839 struct WOW64_FLOATING_SAVE_AREA
6845 DWORD ErrorSelector;
6848 BYTE RegisterArea[80];
6852 #pragma pack (push, 4)
6854 struct WOW64_CONTEXT
6865 WOW64_FLOATING_SAVE_AREA FloatSave;
6886 BYTE ExtendedRegisters[512];
6895 ULONG64 Reserved[2];
6910 struct IMAGEHLP_LINE64
6919 typedef bool (__stdcall *PREAD_PROCESS_MEMORY_ROUTINE64) (HANDLE process, DWORD64 baseAddress,
void* buffer, DWORD size, DWORD* bytesRead);
6920 typedef void* (__stdcall *PFUNCTION_TABLE_ACCESS_ROUTINE64) (HANDLE process, DWORD64 baseAddress);
6921 typedef DWORD64 (__stdcall *PGET_MODULE_BASE_ROUTINE64) (HANDLE process, DWORD64 address);
6922 typedef DWORD64 (__stdcall *PTRANSLATE_ADDRESS_ROUTINE64) (HANDLE process, HANDLE thread, ADDRESS64* address);
6924 typedef void (*unexpected_handler)();
6926 #pragma pack (push, 4)
6928 struct MINIDUMP_THREAD_CALLBACK
6931 HANDLE ThreadHandle;
6933 ULONG SizeOfContext;
6938 struct MINIDUMP_THREAD_EX_CALLBACK
6941 HANDLE ThreadHandle;
6943 ULONG SizeOfContext;
6946 ULONG64 BackingStoreBase;
6947 ULONG64 BackingStoreEnd;
6950 struct MINIDUMP_MODULE_CALLBACK
6953 ULONG64 BaseOfImage;
6956 ULONG TimeDateStamp;
6957 VS_FIXEDFILEINFO VersionInfo;
6959 ULONG SizeOfCvRecord;
6961 ULONG SizeOfMiscRecord;
6964 struct MINIDUMP_INCLUDE_THREAD_CALLBACK
6969 struct MINIDUMP_INCLUDE_MODULE_CALLBACK
6971 ULONG64 BaseOfImage;
6974 struct MINIDUMP_MEMORY_INFO
6976 ULONG64 BaseAddress;
6977 ULONG64 AllocationBase;
6978 ULONG32 AllocationProtect;
6979 ULONG32 __alignment1;
6984 ULONG32 __alignment2;
6987 struct MINIDUMP_USER_STREAM
6994 struct MINIDUMP_USER_STREAM_INFORMATION
6996 ULONG UserStreamCount;
6997 MINIDUMP_USER_STREAM* UserStreamArray;
7000 struct MINIDUMP_CALLBACK_INPUT
7003 HANDLE ProcessHandle;
7008 MINIDUMP_THREAD_CALLBACK Thread;
7009 MINIDUMP_THREAD_EX_CALLBACK ThreadEx;
7010 MINIDUMP_MODULE_CALLBACK Module;
7011 MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread;
7012 MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule;
7016 struct MINIDUMP_CALLBACK_OUTPUT
7020 ULONG ModuleWriteFlags;
7021 ULONG ThreadWriteFlags;
7022 ULONG SecondaryFlags;
7032 unsigned CheckCancel;
7041 MINIDUMP_MEMORY_INFO VmRegion;
7048 struct MINIDUMP_EXCEPTION_INFORMATION
7051 EXCEPTION_POINTERS* ExceptionPointers;
7052 unsigned ClientPointers;
7055 typedef int (WINAPI* MINIDUMP_CALLBACK_ROUTINE) (
void* param, MINIDUMP_CALLBACK_INPUT* input, MINIDUMP_CALLBACK_OUTPUT* output);
7057 struct MINIDUMP_CALLBACK_INFORMATION
7059 MINIDUMP_CALLBACK_ROUTINE CallbackRoutine;
7060 void* CallbackParam;
7065 MiniDumpNormal = 0x00000000,
7066 MiniDumpWithDataSegs = 0x00000001,
7067 MiniDumpWithFullMemory = 0x00000002,
7068 MiniDumpWithHandleData = 0x00000004,
7069 MiniDumpFilterMemory = 0x00000008,
7070 MiniDumpScanMemory = 0x00000010,
7071 MiniDumpWithUnloadedModules = 0x00000020,
7072 MiniDumpWithIndirectlyReferencedMemory = 0x00000040,
7073 MiniDumpFilterModulePaths = 0x00000080,
7074 MiniDumpWithProcessThreadData = 0x00000100,
7075 MiniDumpWithPrivateReadWriteMemory = 0x00000200,
7076 MiniDumpWithoutOptionalData = 0x00000400,
7077 MiniDumpWithFullMemoryInfo = 0x00000800,
7078 MiniDumpWithThreadInfo = 0x00001000,
7079 MiniDumpWithCodeSegs = 0x00002000,
7080 MiniDumpWithoutAuxiliaryState = 0x00004000,
7081 MiniDumpWithFullAuxiliaryState = 0x00008000,
7082 MiniDumpWithPrivateWriteCopyMemory = 0x00010000,
7083 MiniDumpIgnoreInaccessibleMemory = 0x00020000,
7084 MiniDumpWithTokenInformation = 0x00040000
7089 #define FOREGROUND_BLACK ( 0 )
7090 #define FOREGROUND_CYAN ( FOREGROUND_BLUE | FOREGROUND_GREEN )
7091 #define FOREGROUND_MAGENTA ( FOREGROUND_BLUE | FOREGROUND_RED )
7092 #define FOREGROUND_DARKYELLOW ( FOREGROUND_GREEN | FOREGROUND_RED )
7093 #define FOREGROUND_LIGHTGRAY ( FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_RED )
7094 #define FOREGROUND_DARKGRAY ( FOREGROUND_INTENSITY )
7095 #define FOREGROUND_LIGHTBLUE ( FOREGROUND_BLUE | FOREGROUND_INTENSITY )
7096 #define FOREGROUND_LIGHTGREEN ( FOREGROUND_GREEN | FOREGROUND_INTENSITY )
7097 #define FOREGROUND_LIGHTCYAN ( FOREGROUND_CYAN | FOREGROUND_INTENSITY )
7098 #define FOREGROUND_LIGHTRED ( FOREGROUND_RED | FOREGROUND_INTENSITY )
7099 #define FOREGROUND_LIGHTMAGENTA ( FOREGROUND_MAGENTA | FOREGROUND_INTENSITY )
7100 #define FOREGROUND_YELLOW ( FOREGROUND_DARKYELLOW | FOREGROUND_INTENSITY )
7101 #define FOREGROUND_WHITE ( FOREGROUND_LIGHTGRAY | FOREGROUND_INTENSITY )
7103 #define BACKGROUND_BLACK ( 0 )
7104 #define BACKGROUND_CYAN ( BACKGROUND_BLUE | BACKGROUND_GREEN )
7105 #define BACKGROUND_MAGENTA ( BACKGROUND_BLUE | BACKGROUND_RED )
7106 #define BACKGROUND_DARKYELLOW ( BACKGROUND_GREEN | BACKGROUND_RED )
7107 #define BACKGROUND_GRAY ( BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED )
7108 #define BACKGROUND_DARKGRAY ( BACKGROUND_INTENSITY )
7109 #define BACKGROUND_LIGHTBLUE ( BACKGROUND_BLUE | BACKGROUND_INTENSITY )
7110 #define BACKGROUND_LIGHTGREEN ( BACKGROUND_GREEN | BACKGROUND_INTENSITY )
7111 #define BACKGROUND_LIGHTCYAN ( BACKGROUND_CYAN | BACKGROUND_INTENSITY )
7112 #define BACKGROUND_LIGHTRED ( BACKGROUND_RED | BACKGROUND_INTENSITY )
7113 #define BACKGROUND_LIGHTMAGENTA ( BACKGROUND_MAGENTA | BACKGROUND_INTENSITY )
7114 #define BACKGROUND_LIGHTYELLOW ( BACKGROUND_DARKYELLOW | BACKGROUND_INTENSITY )
7115 #define BACKGROUND_WHITE ( BACKGROUND_DARKGRAY | BACKGROUND_INTENSITY )
7127 #if defined (_MSC_VER)
7131 #pragma pack (push, 4) // EXCEPTION_RECORD:
7137 __int32 pForwardCompat;
7138 __int32 pCatchableTypeArray;
7141 struct CatchableTypeArray
7143 __int32 nCatchableTypes;
7144 __int32 arrayOfCatchableTypes[];
7147 struct CatchableType
7151 __int32 thisDisplacement[3];
7152 __int32 sizeOrOffset;
7153 __int32 copyFunction;
7156 #pragma pack (pop) // | pType (ptr/RVA) ---+------> +==================+
7164 #define _TX_MSC__CXX_DETECT_RETHROW( exc ) \
7167 (exc) -> ExceptionCode == EXCEPTION_CPP_MSC && \
7168 (exc) -> NumberParameters >= 3 && \
7170 ((exc)-> ExceptionInformation[0] == EXCEPTION_CPP_MSC_EH_MAGIC_NUMBER1 || \
7171 (exc)-> ExceptionInformation[0] == EXCEPTION_CPP_MSC_EH_MAGIC_NUMBER2 || \
7172 (exc)-> ExceptionInformation[0] == EXCEPTION_CPP_MSC_EH_MAGIC_NUMBER3) && \
7174 (exc) -> ExceptionInformation[2] == 0 \
7187 #if defined (_GCC_VER)
7191 struct __cxa_exception
7196 ::std::type_info* exceptionType;
7197 void (*exceptionDestructor)(
void*);
7201 __cxa_exception* primaryException;
7206 std::unexpected_handler unexpectedHandler;
7207 std::terminate_handler terminateHandler;
7209 __cxa_exception* nextException;
7211 int handlerSwitchValue;
7212 const unsigned char* actionRecord;
7213 const unsigned char* languageSpecificData;
7217 _Unwind_Exception unwindHeader;
7220 struct __cxa_eh_globals
7222 __cxa_exception* caughtExceptions;
7223 unsigned int uncaughtExceptions;
7229 extern "C" ABI::__cxa_eh_globals* __cxa_get_globals();
7243 #define _TX_DLLIMPORT( lib, retval, name, params ) \
7244 retval (WINAPI* name) params = (retval (WINAPI*) params) _txDllImport (lib ".dll", #name, true)
7246 #define _TX_DLLIMPORT_OPT( lib, retval, name, params ) \
7247 retval (WINAPI* name) params = (retval (WINAPI*) params) _txDllImport (lib ".dll", #name, false)
7249 #define _TX_DLLIMPORT_CRT( lib, retval, name, params ) \
7250 retval ( * name) params = (retval ( *) params) _txDllImport (lib ".dll", #name, false)
7252 typedef void (*_tx_FARPROC)();
7254 _tx_FARPROC _txDllImport (
const char dllFileName[],
const char funcName[],
bool required =
true);
7260 _TX_DLLIMPORT (
"GDI32", HDC, CreateCompatibleDC, (HDC dc));
7261 _TX_DLLIMPORT (
"GDI32", HBITMAP, CreateCompatibleBitmap, (HDC dc,
int width,
int height));
7262 _TX_DLLIMPORT (
"GDI32", HGDIOBJ, GetStockObject, (
int object));
7263 _TX_DLLIMPORT (
"GDI32", HGDIOBJ, SelectObject, (HDC dc, HGDIOBJ
object));
7264 _TX_DLLIMPORT (
"GDI32", HGDIOBJ, GetCurrentObject, (HDC dc,
unsigned objectType));
7265 _TX_DLLIMPORT (
"GDI32",
int, GetObjectA, (HGDIOBJ obj,
int bufsize,
void* buffer));
7266 _TX_DLLIMPORT (
"GDI32", DWORD, GetObjectType, (HGDIOBJ
object));
7267 _TX_DLLIMPORT (
"GDI32",
bool, DeleteDC, (HDC dc));
7268 _TX_DLLIMPORT (
"GDI32",
bool, DeleteObject, (HGDIOBJ
object));
7269 _TX_DLLIMPORT (
"GDI32", COLORREF, SetTextColor, (HDC dc, COLORREF color));
7270 _TX_DLLIMPORT (
"GDI32", COLORREF, SetBkColor, (HDC dc, COLORREF color));
7271 _TX_DLLIMPORT (
"GDI32",
int, SetBkMode, (HDC dc,
int bkMode));
7272 _TX_DLLIMPORT (
"GDI32", HFONT, CreateFontA, (
int height,
int width,
int escapement,
int orientation,
7273 int weight, DWORD italic, DWORD underline, DWORD strikeout,
7274 DWORD charSet, DWORD outputPrec, DWORD clipPrec,
7275 DWORD quality, DWORD pitchAndFamily,
const char face[]));
7276 _TX_DLLIMPORT (
"GDI32",
int, EnumFontFamiliesExA, (HDC dc, LPLOGFONT logFont, FONTENUMPROC enumProc,
7277 LPARAM lParam, DWORD reserved));
7278 _TX_DLLIMPORT (
"GDI32", COLORREF, SetPixel, (HDC dc,
int x,
int y, COLORREF color));
7279 _TX_DLLIMPORT (
"GDI32", COLORREF, GetPixel, (HDC dc,
int x,
int y));
7280 _TX_DLLIMPORT (
"GDI32", HPEN, CreatePen, (
int penStyle,
int width, COLORREF color));
7281 _TX_DLLIMPORT (
"GDI32", HBRUSH, CreateSolidBrush, (COLORREF color));
7282 _TX_DLLIMPORT (
"GDI32",
bool, MoveToEx, (HDC dc,
int x,
int y, POINT* point));
7283 _TX_DLLIMPORT (
"GDI32",
bool, LineTo, (HDC dc,
int x,
int y));
7284 _TX_DLLIMPORT (
"GDI32",
bool, Polygon, (HDC dc,
const POINT points[],
int count));
7285 _TX_DLLIMPORT (
"GDI32",
bool, Polyline, (HDC dc,
const POINT points[],
int count));
7286 _TX_DLLIMPORT (
"GDI32",
bool, PolyBezier, (HDC dc,
const POINT points[],
int count));
7287 _TX_DLLIMPORT (
"GDI32",
bool, Rectangle, (HDC dc,
int x0,
int y0,
int x1,
int y1));
7288 _TX_DLLIMPORT (
"GDI32",
bool, RoundRect, (HDC dc,
int x0,
int y0,
int x1,
int y1,
int sizeX,
int sizeY));
7289 _TX_DLLIMPORT (
"GDI32",
bool, Ellipse, (HDC dc,
int x0,
int y0,
int x1,
int y1));
7290 _TX_DLLIMPORT (
"GDI32",
bool, Arc, (HDC dc,
int x0,
int y0,
int x1,
int y1,
7291 int xStart,
int yStart,
int xEnd,
int yEnd));
7292 _TX_DLLIMPORT (
"GDI32",
bool, Pie, (HDC dc,
int x0,
int y0,
int x1,
int y1,
7293 int xStart,
int yStart,
int xEnd,
int yEnd));
7294 _TX_DLLIMPORT (
"GDI32",
bool, Chord, (HDC dc,
int x0,
int y0,
int x1,
int y1,
7295 int xStart,
int yStart,
int xEnd,
int yEnd));
7296 _TX_DLLIMPORT (
"GDI32",
bool, TextOutA, (HDC dc,
int x,
int y,
const char string[],
int length));
7297 _TX_DLLIMPORT (
"GDI32", UINT, SetTextAlign, (HDC dc,
unsigned mode));
7298 _TX_DLLIMPORT (
"GDI32",
bool, GetTextExtentPoint32A, (HDC dc,
const char string[],
int length, SIZE* size));
7299 _TX_DLLIMPORT (
"GDI32",
bool, ExtFloodFill, (HDC dc,
int x,
int y, COLORREF color,
unsigned type));
7300 _TX_DLLIMPORT (
"GDI32",
bool, BitBlt, (HDC dest,
int xDest,
int yDest,
int width,
int height,
7301 HDC src,
int xSrc,
int ySrc, DWORD rOp));
7302 _TX_DLLIMPORT (
"GDI32",
bool, StretchBlt, (HDC dest,
int xDest,
int yDest,
int width,
int height,
7303 HDC src,
int xSrc,
int ySrc,
int wSrc,
int hSrc, DWORD rOp));
7304 _TX_DLLIMPORT (
"GDI32",
bool, PlgBlt, (HDC dest,
const POINT* parallelogram,
7305 HDC src,
int xSrc,
int ySrc,
int width,
int height,
7306 HBITMAP mask,
int xMask,
int yMask));
7307 _TX_DLLIMPORT (
"GDI32",
int, SetDIBitsToDevice, (HDC dc,
int xDest,
int yDest, DWORD width, DWORD height,
7308 int xSrc,
int ySrc,
unsigned startLine,
unsigned numLines,
7309 const void* data,
const BITMAPINFO* info,
unsigned colorUse));
7310 _TX_DLLIMPORT (
"GDI32",
int, GetDIBits, (HDC hdc, HBITMAP hbmp,
unsigned uStartScan,
unsigned cScanLines,
7311 void* lpvBits, BITMAPINFO* lpbi,
unsigned usage));
7312 _TX_DLLIMPORT (
"GDI32",
bool, PatBlt, (HDC dc,
int x0,
int y0,
int width,
int height, DWORD rOp));
7313 _TX_DLLIMPORT (
"GDI32",
int, SetROP2, (HDC dc,
int mode));
7314 _TX_DLLIMPORT (
"GDI32",
int, SetStretchBltMode, (HDC dc,
int mode));
7315 _TX_DLLIMPORT (
"GDI32", DWORD, GdiSetBatchLimit, (DWORD limit));
7316 _TX_DLLIMPORT (
"GDI32", HBITMAP, CreateDIBSection, (HDC dc,
const BITMAPINFO* bmInfo,
unsigned colorUsage,
void **vBits,
7317 HANDLE section, DWORD offset));
7319 _TX_DLLIMPORT (
"User32",
int, DrawTextA, (HDC dc,
const char text[],
int length, RECT* rect,
unsigned format));
7320 _TX_DLLIMPORT (
"User32", HANDLE, LoadImageA, (HINSTANCE inst,
const char name[],
unsigned type,
7321 int sizex,
int sizey,
unsigned mode));
7322 _TX_DLLIMPORT_OPT (
"User32",
bool, IsHungAppWindow, (HWND wnd));
7323 _TX_DLLIMPORT_OPT (
"User32", HWND, GhostWindowFromHungWindow, (HWND wnd));
7325 _TX_DLLIMPORT (
"WinMM",
bool, PlaySound, (
const char sound[], HMODULE mod, DWORD mode));
7327 _TX_DLLIMPORT_OPT (
"MSImg32",
bool, TransparentBlt, (HDC dest,
int destX,
int destY,
int destWidth,
int destHeight,
7328 HDC src,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
7329 unsigned transparentColor));
7330 _TX_DLLIMPORT_OPT (
"MSImg32",
bool, AlphaBlend, (HDC dest,
int destX,
int destY,
int destWidth,
int destHeight,
7331 HDC src,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
7332 BLENDFUNCTION blending));
7334 _TX_DLLIMPORT (
"Kernel32",
void, ExitProcess, (
unsigned retcode));
7335 _TX_DLLIMPORT (
"Kernel32",
bool, TerminateProcess, (HANDLE process,
unsigned retcode));
7336 _TX_DLLIMPORT_OPT (
"Kernel32",
void, FatalExit, (
int retcode));
7337 _TX_DLLIMPORT_OPT (
"Kernel32",
void, FatalAppExitA, (
unsigned action,
const char message[]));
7338 _TX_DLLIMPORT (
"Kernel32", HWND, GetConsoleWindow, (
void));
7339 _TX_DLLIMPORT_OPT (
"Kernel32",
bool, SetConsoleFont, (HANDLE con, DWORD fontIndex));
7340 _TX_DLLIMPORT_OPT (
"Kernel32", DWORD, GetNumberOfConsoleFonts, (
void));
7341 _TX_DLLIMPORT_OPT (
"Kernel32",
bool, GetCurrentConsoleFont, (HANDLE con,
bool maxWnd, CONSOLE_FONT_INFO* curFont));
7342 _TX_DLLIMPORT_OPT (
"Kernel32",
bool, GetCurrentConsoleFontEx, (HANDLE con,
bool maxWnd, CONSOLE_FONT_INFOEX* curFont));
7343 _TX_DLLIMPORT_OPT (
"Kernel32",
bool, SetCurrentConsoleFontEx, (HANDLE con,
bool maxWnd, CONSOLE_FONT_INFOEX* curFont));
7344 _TX_DLLIMPORT_OPT (
"Kernel32",
void, RtlCaptureContext, (CONTEXT* contextRecord));
7345 _TX_DLLIMPORT_OPT (
"Kernel32", USHORT, RtlCaptureStackBackTrace, (DWORD framesToSkip, DWORD framesToCapture,
void** backTrace, DWORD* hash));
7346 _TX_DLLIMPORT_OPT (
"Kernel32",
void*, AddVectoredExceptionHandler, (
unsigned long firstHandler, PVECTORED_EXCEPTION_HANDLER handler));
7347 _TX_DLLIMPORT_OPT (
"Kernel32",
unsigned, RemoveVectoredExceptionHandler,(
void* handler));
7348 _TX_DLLIMPORT_OPT (
"Kernel32",
bool, GetModuleHandleEx, (DWORD flags,
const char moduleName[], HMODULE* module));
7349 _TX_DLLIMPORT_OPT (
"Kernel32",
bool, IsWow64Process, (HANDLE process,
int* isWow64Process));
7350 _TX_DLLIMPORT_OPT (
"Kernel32",
bool, Wow64GetThreadContext, (HANDLE thread, WOW64_CONTEXT* context));
7351 _TX_DLLIMPORT_OPT (
"Kernel32",
bool, SetThreadStackGuarantee, (
unsigned long* stackSize));
7353 _TX_DLLIMPORT (
"OLE32", HRESULT, CoInitialize, (
void*));
7354 _TX_DLLIMPORT (
"OLE32", HRESULT, CoCreateInstance, (REFCLSID clsId, IUnknown*, DWORD, REFIID iId, PVOID* value));
7355 _TX_DLLIMPORT (
"OLE32",
void, CoUninitialize, (
void));
7357 _TX_DLLIMPORT (
"Shell32", HINSTANCE,ShellExecuteA, (HWND wnd,
const char operation[],
const char file[],
7358 const char parameters[],
const char directory[],
int showCmd));
7360 _TX_DLLIMPORT (
"ShlWAPI",
char*, StrStrIA, (
const char string[],
const char search[]));
7361 _TX_DLLIMPORT (
"ShlWAPI",
char*, StrStrIW, (
const wchar_t string[],
const wchar_t search[]));
7363 _TX_DLLIMPORT_OPT (
"NTDLL",
char*, wine_get_version, (
void));
7364 _TX_DLLIMPORT (
"NTDLL", NTSTATUS, NtQueryInformationProcess, (HANDLE process,
int infoClass,
7365 void* processInfo,
unsigned long szProcessInfo,
unsigned long* szReturnInfo));
7367 _TX_DLLIMPORT_CRT (
"MSVCRT",
void, exit, (
int retcode));
7368 _TX_DLLIMPORT_CRT (
"MSVCRT",
void, _cexit, (
void));
7369 _TX_DLLIMPORT_CRT (
"MSVCRT",
unsigned, _fpreset, (
void));
7370 _TX_DLLIMPORT_CRT (
"MSVCRT",
unsigned, _controlfp, (
unsigned control,
unsigned mask));
7371 _TX_DLLIMPORT_CRT (
"MSVCRT", uintptr_t,_beginthread, (
void (__cdecl* start_address) (
void*),
unsigned stack_size,
void* arglist));
7372 _TX_DLLIMPORT_CRT (
"MSVCRT", uintptr_t,_beginthreadex, (
void* security,
unsigned stack_size,
unsigned (__stdcall* start_address) (
void*),
7373 void *arglist,
unsigned init_flag,
unsigned* thread_addr));
7374 _TX_DLLIMPORT_CRT (
"MSVCRT",
char*, __unDName, (
char* outStr,
const char* mangledName,
int outStrLen,
7375 void* (*mallocFunc) (
size_t size),
void (*freeFunc) (
void *pointer),
7376 unsigned short flags));
7377 _TX_DLLIMPORT_CRT (
"MSVCRT", unexpected_handler, set_unexpected, (unexpected_handler handler));
7379 _TX_DLLIMPORT_OPT (
"OpenGL32", HDC, wglGetCurrentDC, (
void));
7380 _TX_DLLIMPORT_OPT (
"OpenGL32",
unsigned, glGetError, (
void));
7381 _TX_DLLIMPORT_OPT (
"Glu32",
const char*, gluErrorString, (
unsigned error));
7383 _TX_DLLIMPORT_OPT (
"DbgHelp*",
bool, MiniDumpWriteDump, (HANDLE process, DWORD processId, HANDLE file, MINIDUMP_TYPE dumpType,
7384 MINIDUMP_EXCEPTION_INFORMATION* exceptionParam,
7385 MINIDUMP_USER_STREAM_INFORMATION* userStreamParam,
7386 MINIDUMP_CALLBACK_INFORMATION* callbackParam));
7388 _TX_DLLIMPORT_OPT (
"DbgHelp*", DWORD, SymSetOptions, (DWORD options));
7389 _TX_DLLIMPORT_OPT (
"DbgHelp*",
bool, SymInitialize, (HANDLE process,
const char userSearchPath[],
bool invadeProcess));
7390 _TX_DLLIMPORT_OPT (
"DbgHelp*",
bool, SymFromAddr, (HANDLE process, DWORD64 addr, DWORD64* offset, SYMBOL_INFO* symbol));
7391 _TX_DLLIMPORT_OPT (
"DbgHelp*",
bool, SymGetLineFromAddr64, (HANDLE process, DWORD64 addr, DWORD* offset, IMAGEHLP_LINE64* line));
7392 _TX_DLLIMPORT_OPT (
"DbgHelp*", DWORD64, SymGetModuleBase64, (HANDLE process, DWORD64 addr));
7393 _TX_DLLIMPORT_OPT (
"DbgHelp*",
bool, SymCleanup, (HANDLE process));
7394 _TX_DLLIMPORT_OPT (
"DbgHelp*",
void*, SymFunctionTableAccess64, (HANDLE process, DWORD64 addrBase));
7395 _TX_DLLIMPORT_OPT (
"DbgHelp*",
bool, StackWalk64, (DWORD arch, HANDLE process, HANDLE thread, STACKFRAME64* frame,
void* ctxRecord,
7396 PREAD_PROCESS_MEMORY_ROUTINE64 readMemoryFunc,
7397 PFUNCTION_TABLE_ACCESS_ROUTINE64 tableAccessFunc,
7398 PGET_MODULE_BASE_ROUTINE64 getModuleBaseFunc,
7399 PTRANSLATE_ADDRESS_ROUTINE64 translateAddressFunc));
7401 _TX_DLLIMPORT_OPT (
"MgwHelp*", DWORD, SymSetOptions, (DWORD options));
7402 _TX_DLLIMPORT_OPT (
"MgwHelp*",
bool, SymInitialize, (HANDLE process,
const char userSearchPath[],
bool invadeProcess));
7403 _TX_DLLIMPORT_OPT (
"MgwHelp*",
bool, SymFromAddr, (HANDLE process, DWORD64 addr, DWORD64* offset, SYMBOL_INFO* symbol));
7404 _TX_DLLIMPORT_OPT (
"MgwHelp*",
bool, SymGetLineFromAddr64, (HANDLE process, DWORD64 addr, DWORD* offset, IMAGEHLP_LINE64* line));
7405 _TX_DLLIMPORT_OPT (
"MgwHelp*", DWORD64, SymGetModuleBase64, (HANDLE process, DWORD64 addr));
7406 _TX_DLLIMPORT_OPT (
"MgwHelp*",
bool, SymCleanup, (HANDLE process));
7407 _TX_DLLIMPORT_OPT (
"MgwHelp*",
void*, SymFunctionTableAccess64, (HANDLE process, DWORD64 addrBase));
7408 _TX_DLLIMPORT_OPT (
"MgwHelp*",
bool, StackWalk64, (DWORD arch, HANDLE process, HANDLE thread, STACKFRAME64* frame,
void* ctxRecord,
7409 PREAD_PROCESS_MEMORY_ROUTINE64 readMemoryFunc,
7410 PFUNCTION_TABLE_ACCESS_ROUTINE64 tableAccessFunc,
7411 PGET_MODULE_BASE_ROUTINE64 getModuleBaseFunc,
7412 PTRANSLATE_ADDRESS_ROUTINE64 translateAddressFunc));
7430 const int _TX_IDM_ABOUT = 40000,
7431 _TX_IDM_CONSOLE = 40001,
7432 _TX_WM_CREATEWND = 0x7FF0,
7433 _TX_WM_DESTROYWND = 0x7FF1;
7437 int _txInitialize();
7440 HWND _txCanvas_CreateWindow (
const SIZE* size);
7443 bool _txCanvas_OnCREATE (HWND wnd);
7444 bool _txCanvas_OnDESTROY (HWND wnd);
7445 bool _txCanvas_OnCLOSE (HWND);
7446 bool _txCanvas_OnPAINT (HWND wnd);
7447 bool _txCanvas_OnKEYDOWN (HWND wnd, WPARAM vk, LPARAM info);
7448 bool _txCanvas_OnCHAR (HWND wnd, WPARAM ch, LPARAM info);
7449 bool _txCanvas_OnTIMER (HWND wnd, WPARAM
id);
7450 bool _txCanvas_OnMOUSEMOVE (HWND wnd, WPARAM buttons, LPARAM coords);
7451 bool _txCanvas_OnMOUSELEAVE (HWND wnd);
7452 bool _txCanvas_OnCREATEWND (HWND wnd, WPARAM, LPARAM lpar);
7453 bool _txCanvas_OnDESTROYWND (HWND wnd, WPARAM, LPARAM lpar);
7454 bool _txCanvas_OnCmdCONSOLE (HWND wnd, WPARAM cmd);
7455 bool _txCanvas_OnCmdABOUT (HWND wnd, WPARAM cmd);
7457 unsigned WINAPI _txCanvas_ThreadProc (
void* data);
7458 LRESULT CALLBACK _txCanvas_WndProc (HWND wnd, UINT msg, WPARAM wpar, LPARAM lpar);
7460 int _txCanvas_SetRefreshLock (
int count);
7462 HDC _txBuffer_Create (HWND wnd = NULL, const POINT* size = NULL, HBITMAP bitmap = NULL,
7464 bool _txBuffer_Delete (HDC* dc);
7465 bool _txBuffer_Select (HGDIOBJ obj, HDC dc =
txDC());
7467 HWND _txConsole_Attach();
7469 bool _txConsole_Detach (
bool activate);
7470 bool _txConsole_Draw (HDC dc);
7471 bool _txConsole_SetUnicodeFont();
7473 const
char* txRegisterClass (const
char classId[], WNDPROC wndProc,
unsigned style,
int backBrush,
int wndExtra);
7474 HWND txCreateExtraWindow (CREATESTRUCT createData);
7476 int _txSetFinishedText (HWND wnd);
7477 void _txPauseBeforeTermination (HWND canvas);
7478 int _txIsParentWaitable (DWORD* parentPID = NULL)
tx_nodiscard;
7481 LRESULT CALLBACK _txPlayVideo_WndProc (HWND wnd, UINT msg, WPARAM wpar, LPARAM lpar);
7484 bool _txCreateShortcut (const
char shortcutName[],
7485 const
char fileToLink[], const
char args[] = NULL, const
char workDir[] = NULL,
7486 const
char description[] = NULL,
int cmdShow = SW_SHOWNORMAL,
7487 const
char iconFile[] = NULL,
int iconIndex = 0,
int fontSize = 0,
7488 COORD bufSize =
ZERO (COORD), COORD wndSize =
ZERO (COORD), COORD wndOrg =
ZERO (COORD));
7490 void* _tx_DLGTEMPLATE_Create (
void* globalMem,
size_t bufsize, DWORD style, DWORD exStyle,
7491 WORD controls,
short x,
short y,
short cx,
short cy,
7492 const
char caption[], const
char font[], WORD fontsize,
7495 void* _tx_DLGTEMPLATE_Add (
void* dlgTemplatePtr,
size_t bufsize, DWORD style, DWORD exStyle,
7496 short x,
short y,
short cx,
short cy,
7497 WORD
id, const
char wclass[], const
char caption[]);
7499 const
char* _txError (const
char file[] = NULL,
int line = 0, const
char func[] = NULL,
unsigned color = 0,
7500 const
char msg[] = NULL, ...)
tx_printfy (5);
7501 const
char* _txProcessError (const
char file[],
int line, const
char func[],
unsigned color,
7502 const
char msg[], va_list args);
7503 void _txOnTerminate();
7504 void _txOnUnexpected();
7505 void _txOnPureCall();
7506 void _txOnNewHandlerAnsi();
7507 int _txOnNewHandler (
size_t size);
7508 void _txOnSignal (
int signal = 0,
int fpe = 0);
7509 BOOL WINAPI _txOnConsoleCtrlEvent (DWORD type);
7510 void _txOnSecurityError (
int code,
void*);
7511 void _txOnSecurityErrorAnsi (const
char* msg,
void* ptr,
int code);
7512 int _txOnMatherr (_exception* except);
7513 void _txOnInvalidParam (const
wchar_t* expr, const
wchar_t* func, const
wchar_t* file,
7514 unsigned line, uintptr_t);
7515 int _txOnAllocHook (
int type,
void* data,
size_t size,
int use,
long request,
7516 const
unsigned char* file,
int line);
7517 int _txOnRTCFailure (
int type, const
char* file,
int line, const
char* module, const
char* format, ...)
tx_printfy (5);
7518 int _txOnErrorReport (
int type, const
char* text,
int* ret);
7519 int tx_glGetError (
int setError = INT_MIN);
7522 void _txOnExit (
int retcode);
7523 void _txOnFatalExit (
int retcode);
7524 void _txOnExitProcess (
unsigned retcode);
7525 void _txOnFatalAppExitA (
unsigned action, const
char message[]);
7526 bool _txOnTerminateProcess (HANDLE process,
unsigned retcode);
7527 LPTOP_LEVEL_EXCEPTION_FILTER WINAPI
7528 _txOnSetUnhandledExceptionFilter (LPTOP_LEVEL_EXCEPTION_FILTER filter);
7529 void _txWatchdogTerminator (
void* timeout);
7531 long WINAPI _txVectoredExceptionHandler (EXCEPTION_POINTERS* exc);
7532 long WINAPI _txUnhandledExceptionFilter (EXCEPTION_POINTERS* exc);
7533 long _txOnExceptionSEH (EXCEPTION_POINTERS* exc, const
char func[]);
7534 intptr_t _txDumpExceptionSEH (
char what[], intptr_t size, const EXCEPTION_RECORD* exc, const
char func[]);
7535 intptr_t _txDumpExceptionObj (
char what[], intptr_t size,
void*
object,
size_t sizeObj, const std::type_info* type);
7536 intptr_t _txDumpExceptionCPP (
char what[], intptr_t size,
unsigned code = 0,
7537 unsigned params = 0, const ULONG_PTR info[] = NULL);
7539 void _txStackBackTrace (const
char file[] = "?",
int line = 0, const
char func[] = "?",
7540 bool readSource = true);
7541 const
char* _txCaptureStackBackTrace (
int framesToSkip = 0,
bool readSource = true,
7542 CONTEXT* context = NULL, HANDLE thread = GetCurrentThread());
7543 int _txStackWalk (
int framesToSkip,
size_t szCapture,
void* capture[],
unsigned long* backTraceHash,
7544 CONTEXT* context = NULL, HANDLE thread = GetCurrentThread());
7545 const
char* _txCaptureStackBackTraceTX (
int framesToSkip = 0,
bool readSource = false);
7547 const
char* _txSymPrintFromAddr (
void* addr = NULL, const
char format[] = NULL, ...)
tx_printfy (2);
7548 bool _txSymGetFromAddr (
void* addr, Win32::SYMBOL_INFO** symbol = NULL,
7549 Win32::IMAGEHLP_LINE64** line = NULL, const
char** module = NULL,
7550 const
char** source = NULL,
int context = 2);
7551 intptr_t _txReadSource (
char buf[], intptr_t size, const
char file[],
7552 int linStart = 0,
int linEnd = INT_MIN,
int linMark = INT_MIN);
7553 bool _txCreateMiniDump (EXCEPTION_POINTERS* exc);
7555 uintptr_t _txSetProcAddress (const
char funcName[], uintptr_t newFunc, const
char dllName[] = NULL,
7556 int useHotPatching = false, HMODULE module = NULL,
bool debug = false);
7558 PROCESSENTRY32* _txFindProcess (
unsigned pid = GetCurrentProcessId())
tx_nodiscard;
7559 bool _txKillProcess (DWORD pid);
7560 bool _txIsBadReadPtr (const
void* address);
7561 bool _txCheckSourceCP (
int needCP =
_TX_CODEPAGE,
bool verbose = true);
7562 bool _txGetCommandLine (
wchar_t cmdLine[],
size_t szCmdLine,
unsigned pid = _getpid());
7563 IMAGE_NT_HEADERS*_txGetNtHeaders (HMODULE module = GetModuleHandle (NULL))
tx_nodiscard;
7566 intptr_t _tx_snprintf_s (
char stream[], intptr_t size, const
char format[], ...)
tx_printfy (3);
7567 intptr_t _tx_vsnprintf_s (
char stream[], intptr_t size, const
char format[], va_list arg);
7568 void txReopenStdio();
7570 #if defined (_CLANG_VER) && !defined (_MSC_VER)
7571 void _txLibCppDebugFunction (std::__libcpp_debug_info
const& info);
7574 #if defined (__CYGWIN__)
7577 int _putch (
int ch);
7585 #if !defined (NDEBUG)
7587 #define _TX_ARGUMENT_FAILED( cond ) ( !(cond) && \
7588 (SetLastErrorEx (ERROR_BAD_ARGUMENTS, 0), 1) && \
7589 (assert (cond), true) )
7591 #define _TX_TXWINDOW_FAILED() ( !txOK() && \
7592 (SetLastErrorEx (ERROR_INVALID_DATA, 0), 1) && \
7593 (TX_ERROR ("\a" " ."), 1) )
7595 #define _TX_HDC_FAILED( dc ) ( !Win32::GetObjectType (dc) && \
7596 (SetLastErrorEx (ERROR_INVALID_DATA, 0), 1) && \
7597 (TX_ERROR (" \"%s\" . , , " \
7599 #define _TX_DEFAULT_HDC_FAILED(dc) ( (!(dc) && \
7600 _TX_TXWINDOW_FAILED()) || _TX_HDC_FAILED (dc) )
7603 #define _TX_ARGUMENT_FAILED( cond ) ( !(cond) && \
7604 (SetLastErrorEx (ERROR_BAD_ARGUMENTS, 0), 1) )
7606 #define _TX_TXWINDOW_FAILED() ( !txOK() && \
7607 (SetLastErrorEx (ERROR_INVALID_DATA, 0), 1) )
7609 #define _TX_HDC_FAILED( dc ) ( !Win32::GetObjectType (dc) && \
7610 (SetLastErrorEx (ERROR_INVALID_DATA, 0), 1) )
7612 #define _TX_DEFAULT_HDC_FAILED(dc) ( !(dc) && \
7613 (SetLastErrorEx (ERROR_INVALID_DATA, 0), 1) )
7620 #if !defined (NDEBUG)
7621 #define _TX_ON_DEBUG( code ) { code; }
7623 #define _TX_ON_DEBUG( code ) ;
7629 #define _TX_UNEXPECTED( ... ) $$ _txError (NULL, 0, NULL, 0, ##__VA_ARGS__)
7634 #define _TX_CALL( func, param ) ( (func)? ((func) param) : 0 )
7635 #define _TX_CALLv( func, param ) ( (func)? ((func) param) : (void)0 )
7640 #define _txWaitFor( cond, time ) { for (DWORD _t = GetTickCount() + (time); \
7641 !(cond) && GetTickCount() < _t; \
7642 Sleep (_txWindowUpdateInterval)) ; \
7644 _txTrace (__FILE__, __LINE__, NULL, "WARNING: Timeout: " #cond "."); }
7648 #define _txSetJmp() ( setjmp (_txDumpExceptionObjJmp) == 0 )
7650 #define _txClearJmp() { *(unsigned long long*) _txDumpExceptionObjJmp = 0; }
7669 int _txInitialized =
_TX_NOINIT || _txInitialize();
7671 volatile const unsigned _txCanaryFirst = 0x776F656D;
7673 volatile unsigned _txMainThreadId = 0;
7674 volatile HANDLE _txMainThread = NULL;
7676 volatile unsigned _txCanvas_ThreadId = 0;
7677 volatile HANDLE _txCanvas_Thread = NULL;
7678 volatile HWND _txCanvas_Window = NULL;
7680 HDC _txCanvas_BackBuf[2] = {NULL,
7683 RGBQUAD* _txCanvas_Pixels = NULL;
7685 HBITMAP _txStockBitmap = NULL;
7688 CRITICAL_SECTION _txCanvas_LockBackBuf = {0,-1};
7690 UINT_PTR _txCanvas_RefreshTimer = 1;
7691 volatile int _txCanvas_RefreshLock = 0;
7693 ::std::vector<HDC>* _txCanvas_UserDCs = NULL;
7695 volatile bool _txConsole_IsBlinking =
true;
7697 bool _txConsole =
false;
7698 bool _txMain =
false;
7699 bool _txIsDll =
false;
7700 volatile bool _txRunning =
false;
7701 volatile bool _txExit =
false;
7703 volatile POINT _txMousePos = {-1,-1};
7704 volatile unsigned _txMouseButtons = 0;
7706 volatile WNDPROC _txAltWndProc = NULL;
7708 _tx_thread _txLoc _txLoc::Cur = {};
7710 volatile int _txErrors = 0;
7711 int _txOGLError = 0;
7712 volatile long _txSENumber = 0;
7713 volatile long _txSEFatalNumber = 0;
7717 LPTOP_LEVEL_EXCEPTION_FILTER _txPrevUEFilter = NULL;
7719 jmp_buf _txDumpExceptionObjJmp = {};
7721 const volatile uintptr_t _txForceImport[] = { (uintptr_t) ::TerminateProcess, (uintptr_t) ::ExitProcess,
7722 (uintptr_t) ::FatalExit, (uintptr_t) ::FatalAppExitA,
7723 (uintptr_t) ::exit, (uintptr_t) Win32::_controlfp,
7724 (uintptr_t) Win32::Polyline, (uintptr_t) Win32::PolyBezier,
7725 (uintptr_t) Win32::RoundRect, (uintptr_t) Win32::RemoveVectoredExceptionHandler,
7726 (uintptr_t) Win32::PlgBlt, (uintptr_t) Win32::RtlCaptureStackBackTrace,
7727 (uintptr_t) Win32::SymInitialize, (uintptr_t) Win32::MinGW::SymInitialize,
7728 (uintptr_t) Win32::SymSetOptions, (uintptr_t) Win32::MinGW::SymSetOptions,
7729 (uintptr_t) Win32::SymGetLineFromAddr64, (uintptr_t) Win32::MinGW::SymGetLineFromAddr64,
7730 (uintptr_t) Win32::SymFromAddr, (uintptr_t) Win32::MinGW::SymFromAddr,
7731 (uintptr_t) Win32::SymCleanup, (uintptr_t) Win32::MinGW::SymCleanup,
7732 (uintptr_t) Win32::SymGetModuleBase64, (uintptr_t) Win32::MinGW::SymGetModuleBase64,
7733 (uintptr_t) Win32::SymFunctionTableAccess64, (uintptr_t) Win32::MinGW::SymFunctionTableAccess64,
7734 (uintptr_t) Win32::StackWalk64, (uintptr_t) Win32::MinGW::StackWalk64,
7735 (uintptr_t) Win32::StrStrIA, (uintptr_t) Win32::Wow64GetThreadContext };
7737 volatile const unsigned _txCanaryLast = 0x5E2E2E5E;
7755 if (_txInitialized)
return 1;
7758 #if defined (_TX_ALLOC_BREAK) && defined (_MSC_VER) // See http://msdn.microsoft.com/en-us/library/w2fhc9a3%28v=vs.90%29.aspx
7759 _CrtSetBreakAlloc (_TX_ALLOC_BREAK);
7762 #if defined (_TX_ALLOW_TRACE)
7766 _TX_ON_DEBUG (OutputDebugString (
"\n");
7769 OutputDebugString (
"\n"));
7771 _txMainThreadId = GetCurrentThreadId();
7772 _txMainThread = OpenThread (THREAD_ALL_ACCESS,
false, _txMainThreadId);
7774 $3 _txIsDll = _txInDll();
7778 $ _txConsole = ! FindAtom (
"_txConsole");
7779 $ (void) AddAtom (
"_txConsole");
7787 $ _TX_CALL (Win32::SetThreadStackGuarantee, (&stackSize));
7796 $ _TX_CALL (Win32::AddVectoredExceptionHandler, (1, (PVECTORED_EXCEPTION_HANDLER) _txVectoredExceptionHandler));
7797 $ _txPrevUEFilter = SetUnhandledExceptionFilter ( (LPTOP_LEVEL_EXCEPTION_FILTER) _txUnhandledExceptionFilter);
7800 $ ::std::set_terminate (_txOnTerminate);
7801 $ ::std::set_new_handler (_txOnNewHandlerAnsi);
7802 $ _TX_CALL (Win32::set_unexpected, (_txOnUnexpected));
7804 #if defined (_CLANG_VER) && !defined (_MSC_VER)
7805 $ ::std::__libcpp_debug_function = _txLibCppDebugFunction;
7808 $ SetConsoleCtrlHandler (_txOnConsoleCtrlEvent,
true);
7810 $ SetErrorMode (SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
7812 #if defined (_MSC_VER)
7814 $ _set_printf_count_output (1);
7816 $ _set_new_handler (_txOnNewHandler);
7817 $ _set_new_mode (1);
7819 #if !defined (_CLANG_VER)
7821 $ _CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF);
7822 $ _CrtSetAllocHook (_txOnAllocHook);
7824 $
unsigned mode = _CRTDBG_MODE_FILE;
7825 $
if (_CrtSetReportHook2 (_CRT_RPTHOOK_INSTALL, (_CRT_REPORT_HOOK) _txOnErrorReport) > 0) mode = 0;
7827 $ _CrtSetReportMode (_CRT_WARN, _CRTDBG_MODE_DEBUG | mode);
7828 $ _CrtSetReportMode (_CRT_ERROR, _CRTDBG_MODE_DEBUG | mode | _CRTDBG_MODE_WNDW);
7829 $ _CrtSetReportMode (_CRT_ASSERT, _CRTDBG_MODE_DEBUG | mode | _CRTDBG_MODE_WNDW);
7830 $ _CrtSetReportFile (_CRT_WARN, _CRTDBG_FILE_STDERR);
7831 $ _CrtSetReportFile (_CRT_ERROR, _CRTDBG_FILE_STDERR);
7832 $ _CrtSetReportFile (_CRT_ASSERT, _CRTDBG_FILE_STDERR);
7836 $ _set_abort_behavior (_WRITE_ABORT_MSG, _WRITE_ABORT_MSG);
7837 $ _set_abort_behavior (0, _CALL_REPORTFAULT);
7839 $ _RTC_SetErrorFunc (_txOnRTCFailure);
7840 $ _set_purecall_handler (_txOnPureCall);
7841 $ _set_invalid_parameter_handler (_txOnInvalidParam);
7845 #if defined (__STDC_LIB_EXT1__)
7846 $ ::std::set_constraint_handler_s (_txOnSecurityErrorAnsi);
7849 #if !defined (__CYGWIN__) && defined (_GCC_VER) && (_GCC_VER >= 530) && !defined (i386)
7850 $ __setusermatherr (_txOnMatherr);
7853 #if !defined (__CYGWIN__)
7854 $ _set_error_mode (_OUT_TO_MSGBOX | _OUT_TO_STDERR);
7857 $ HWND console = _txConsole_Attach();
7861 $ InitializeCriticalSection (&_txCanvas_LockBackBuf);
7863 $ _txSetProcAddress (
"ExitProcess", (uintptr_t) _txOnExitProcess,
"KERNEL32.DLL");
7864 $ _txSetProcAddress (
"TerminateProcess", (uintptr_t) _txOnTerminateProcess,
"KERNEL32.DLL");
7865 $ _txSetProcAddress (
"FatalExit", (uintptr_t) _txOnFatalExit,
"KERNEL32.DLL");
7866 $ _txSetProcAddress (
"FatalAppExitA", (uintptr_t) _txOnFatalAppExitA,
"KERNEL32.DLL");
7867 $ _txSetProcAddress (
"UnhandledExceptionFilter", (uintptr_t) _txUnhandledExceptionFilter,
"KERNEL32.DLL",
true);
7868 $ _txSetProcAddress (
"SetUnhandledExceptionFilter", (uintptr_t) _txOnSetUnhandledExceptionFilter,
"KERNEL32.DLL");
7869 $ _txSetProcAddress (
"exit", (uintptr_t) _txOnExit);
7870 $ _txSetProcAddress (
"_cexit", (uintptr_t) _txOnCExit);
7872 $ atexit (_txCleanup);
7880 $ srand ((
unsigned) time (NULL));
7885 #if !defined (__CYGWIN__)
7890 $ HDC dc = Win32::CreateCompatibleDC (NULL); dc
asserted;
7891 $ _txStockBitmap = (HBITMAP) Win32::SelectObject (dc, Win32::CreateCompatibleBitmap (dc, 1, 1)); _txStockBitmap
asserted;
7892 $ Win32::DeleteObject (Win32::SelectObject (dc, _txStockBitmap))
asserted;
7900 bool _txCheckSourceCP (
int needCP ,
bool verbose )
7902 $3
const char* sCodePage = NULL;
7905 $
switch (((
unsigned const char*)
"